
I expected result as below
In above output i want count of student who paid their fees. at the same time i want to group that count by fee_type, date and class_division.I am using PIVOT for achieve this result.
Following is my query
But not getting result as i expected.
This is what i am getting after execution of my query. which is totally wrong.
Please let me know if there is any solution to get expected result.
Thanks
ali tuncerPosted Oct 13, 2016, 10:28 PM
try this way :
from
(
select sid,(class_division+ ' ' +fee_type) as CDFT,date
from dbo.TableName
) t
pivot(
count(sid)
for CDFT in ([5 th A Stationary],[5 th B Stationary],[5 th A Gurukul],[5 th B Gurukul],[5 th C Stationary],[5 th C Gurukul])
) as pvt
Guest UserPosted Oct 17, 2016, 4:41 AM