Hey guys,
I am having a problem summing up rows with group by. Here are both queries, the first using group by, the second not using it:
[SQL]
SELECT SUM(bytes_in + bytes_out) * multiplier as total_bytes FROM jobs
AS Job
WHERE account_id
= ‘431df003555ebd4ecf08f3df53049cc5’ AND DATE_FORMAT(created, ‘%Y-%m-%d %H:%i:%s’) >= ‘2010-07-01 00:00:00’ AND DATE_FORMAT(created, ‘%Y-%m-%d %H:%i:%s’) < ‘2010-07-31 00:00:00’ GROUP BY robot;
[/SQL]
Results in:
2252176.00
0.00
1969289.00
2500347.00
The second query is:
[SQL]
SELECT SUM(bytes_in + bytes_out) * multiplier as total_bytes FROM jobs
AS Job
WHERE account_id
= ‘431df003555ebd4ecf08f3df53049cc5’ AND DATE_FORMAT(created, ‘%Y-%m-%d %H:%i:%s’) >= ‘2010-07-01 00:00:00’ AND DATE_FORMAT(created, ‘%Y-%m-%d %H:%i:%s’) < ‘2010-07-31 00:00:00’;
[/SQL]
which results in
8523512.00
As you can see the latter result is not the sum of the sub-sums from the first query. Can anybody please point me in the right direction?
Thanks!