SQL sum 2 different column by different condtion then subtraction and add
问题 what I am trying is kind of complex, I will try my best to explain. I achieved the first part which is to sum the column by hours. example ID TIMESTAMP CUSTAFFECTED 1 10-01-2013 01:00:23 23 2 10-01-2013 03:00:23 55 3 10-01-2013 05:00:23 2369 4 10-01-2013 04:00:23 12 5 10-01-2013 01:00:23 1 6 10-01-2013 12:00:23 99 7 10-01-2013 01:00:23 22 8 10-01-2013 02:00:23 3 output would be Hour TotalCALLS CUSTAFFECTED 10/1/2013 01:00 3 46 10/1/2013 02:00 1 3 10/1/2013 03:00 1 55 10/1/2013 04:00 1 12 10/1