Hi i have a table like this
Activity Date
---------------------
0 2012-11-20
1 2012-11-20
1 2012-11-20
1 2012-11-21
1 2012-11-21
0 2012-11-22
I need to select the record as
Day-wise total 0's 1's Date
------------------------------------------
3 1 2 2012-11-20
2 0 2 2012-11-21
1 1 0 2012-11-22
What you need is a
GROUP BY date,COUNT(Activity)to get Day-wise total and aCASEexpression to pivot the values of 1’s and 0’s. I usedSUMhere but it acts likeCOUNTlike so:SQL Fiddle Demo