Answer the question
In order to leave comments, you need to log in
SUM of a column of numbers with a comma?
As a result, only integers are calculated, tens and hundreds are not taken into account.
48.22
48.18
65
30.16
50
35.17
28.41
150
27.04
141
33.56
30.20
30.12
45.21
90
100
115
180
10.04
15.05
4.02
CREATE TABLE excel (
Start varchar(255),
Duration varchar(255),
Position varchar(255),
Volume varchar(255),
Sensor_name varchar(255),
Geofences_Objects varchar(255),
Fueled varchar(255),
Deviation varchar(255)
);
Answer the question
In order to leave comments, you need to log in
If the data is to be summarized, then there should not be any comma in them. The decimal separator for data in mysql is DOT.
And numeric data must be stored in the types of fields intended for this.
The list can be found in the documentation: https://dev.mysql.com/doc/refman/8.0/en/numeric-ty... and choose the most suitable one. It can be either a fixed point type (DECIMAL) or a floating point type (FLOAT).
Somewhere like this, but it's better to change the types in the database
SELECT SUM(duration) as dumb,
SUM(CAST(REPLACE(duration,',','.') AS DECIMAL(30,2))) as casted
FROM test.testtable;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question