I am trying to aggregate some call records and doing something wrong - but not sure what.
I have the following query:
SELECT 
    c.name, 
    IF(MONTH(start) = 1, SUM(duration),0) AS 'Jan',
    IF(MONTH(start) = 2, SUM(duration),0) AS 'Feb',
    IF(MONTH(start) = 3, SUM(duration),0) AS 'Mar',
    IF(MONTH(start) = 4, SUM(duration),0) AS 'Apr',
    IF(MONTH(start) = 5, SUM(duration),0) AS 'Jun',
    IF(MONTH(start) = 6, SUM(duration),0) AS 'Jul',
    IF(MONTH(start) = 7, SUM(duration),0) AS 'Aug'
FROM
    call_history ch, client c
WHERE
    ch.client_reseller_id = c.id
GROUP BY ch.client_reseller_id
ORDER BY c.name;
The field start contains the date/time of a call. The table only contains records for one year, so no worries about not filtering on year. 
The results I get are not as expected:
+--------------------------------+----------+------+------+--------+------+------+------+
| name                           | Jan      | Feb  | Mar  | Apr    | Jun  | Jul  | Aug  |      
|+-------------------------------+----------+------+------+--------+------+------+------+
| Come company                   |  5243080 |    0 |    0 |      0 |    0 |    0 |    0 |
| Other cust                     |  4085085 |    0 |    0 |      0 |    0 |    0 |    0 |
| Someone                        |  1449543 |    0 |    0 |      0 |    0 |    0 |    0 |
| Demo Reseller                  |     2342 |    0 |    0 |      0 |    0 |    0 |    0 |
+--------------------------------+----------+------+------+--------+------+------+------+
What am I doing wrong?
 
     
     
    