I have data like this format…
ID id date time total
-----------------------------------------------------------
51 192 2012-08-14 00:00:00.000 02:10 PM 4900.00
51 191 2012-08-11 00:00:00.000 03:20 PM 5500.00
51 35 2012-08-17 00:00:00.000 10:30 AM 2900.00
51 35 2012-08-17 00:00:00.000 11:50 AM 10800.00
51 192 2012-10-23 00:00:00.000 04:00 PM 2900.00
51 192 2012-10-23 00:00:00.000 03:00 PM 2900.00
51 192 2012-10-23 00:00:00.000 10:10 AM 2900.00
51 192 2012-10-23 00:00:00.000 02:50 PM 2300.00
51 191 2012-11-16 00:00:00.000 04:00 PM 2900.00
I would like to display sum(total) on a monthly basis. If bookings are not available entire month that month should display 0 value. Because I would like to plot that month value to chart.
Could you please help on this query?
try this:
SQL fiddle demo