I have a simple query:
SELECT
DateAndTime,
count(Load), min(Load), max(Load), sum(Load)
FROM
UpdatedRegions
GROUP BY
DateAndTime
ORDER BY
DateAndTime;
As you can see, I’m trying to get info about the variable “Load” at each timestep. Example data is below:
DateAndTime Load
2028-01-01 00:00:00 9,382.3938
2028-01-01 00:00:00 4,662.4381
2028-01-01 00:00:00 2,328.2232
2028-01-01 00:00:00 815.0305
2028-01-01 00:00:00 6,118.7683
2028-01-01 00:00:00 1,791.7472
2028-01-01 00:00:00 228.7977
2028-01-01 01:00:00 8,865.7735
2028-01-01 01:00:00 4,436.1125
2028-01-01 01:00:00 2,236.8587
2028-01-01 01:00:00 789.5337
2028-01-01 01:00:00 5,787.2574
2028-01-01 01:00:00 1,712.3446
The problem is that I’m getting unexplainable results for SUM and TOTAL. While the count, min, and max are correct, it returns 1065.8282 for the SUM at 2028-01-01 00:00:00. I get the same strange answer if I use TOTAL. It seems like my GROUP BY clause is working since it return count, min, and max correctly.
What am I doing wrong? I tried this in two different versions of SQLite (3.13.0 and 3.41.2).
sammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.