August 11, 2008 at 3:56 am
Hi,
I need help to solve following issue:-
I have a table with following data
Movi Sunday Monday Tuesday Wednesday Thrusday Friday Saturday
1 0 0 1 1 1 1 1
2 1 1 1 1 0 0 0
3 1 1 1 1 1 1 1
I need to have result into following set
Days Count
Sunday 2
Monday 2
Tuesday 3
Wednesday 3
Thrusday 2
Friday 2
Saturday 2
Thanks!
Naveen
August 11, 2008 at 4:23 am
SELECT Day
, SUM([Count])
FROM ( SELECT Sunday
, Monday
, Tuesday
, Wednesday
, Thrusday
, Friday
FROM mt
) p UNPIVOT ( [Count] FOR Day IN ( Sunday, Monday, Tuesday, Wednesday,
Thrusday, Friday ) )AS unpvt
GROUP BY Day
Regards,
Andras
August 11, 2008 at 4:25 am
replace the 😉 with a ), and mt with the name of your table.
- Andras
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply