September 19, 2010 at 11:12 pm
Hi,
Been a while since I have visited here. I have got a query which gives me a result set shown below.
SEQ GROUPNAME DATADATE DATADAY TOTALCOUNT
1Mail In 2010-08-16MON 540
1Mail In 2010-08-17TUE 576
1Mail In 2010-08-18WED 480
1Mail In 2010-08-19THU 198
1Mail In 2010-08-20FRI 510
1Mail In 2010-09-20TODAY265
2Mail Out 2010-08-16MON 348
2Mail Out 2010-08-17TUE 282
2Mail Out 2010-08-18WED 462
2Mail Out 2010-08-19THU 384
2Mail Out 2010-08-20FRI 72
2Mail Out 2010-09-20TODAY307
How do I PIVOT it to get a final result set shown below?
GROUPNAME MON TUE WED THU FRI TODAY TOTAL (ex. TODAY) AVG
Mail In 540 576 480 198 510 265 2304 460.8
Mail Out 348 282 462 384 72 307 1548 309.6
Any help would be appreciated. Just to clarify, "Mail In" and "Mail Out" are just examples, there are more than 10 categories but I didn't feel it was necessary to post all categories and thus making this too long to use.
WRACK
CodeLake
September 19, 2010 at 11:28 pm
No replies to this thread please. Direct replies to:http://www.sqlservercentral.com/Forums/Topic989110-392-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply