Sum of 20 digits in MySQL

Asked 2 years ago, Updated 2 years ago, 36 views

Hello, I'm a beginner developer. In MYSQL, if you add up to 20 characters of 300 digits, as shown below,

substring('121111111111111111111221111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111',41,58) + substring('121111111111111111111221111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111121111111111111111111211111111111111111112111111111111111111',41,58)

1211111111111111111112111111111111111111121111111111111111 + 1211111111111111111112111111111111111111121111111111111111 = 2422222222222222222224222222222222222222242222222222222222

I want to get the above results, but the following results are derived. The same applies to transformations using cast() or convert() functions. I ask for your help me.

2422222222222222200000000000000000000000000000000000000000.0000000000000000000000000000000

mysql summation

2022-09-22 21:29

1 Answers

I solved it. Thank you.

SELECT CONVERT(SUBSTRING( stringval ,41,58),DECIMAL(65)) + + CONVERT(SUBSTRING( stringval ,41,58),DECIMAL(65))


2022-09-22 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.