January 14, 2010 at 9:42 am
I think I got to a point where I can display the result by date.
SELECT[1/7/2009],
[1/9/2009],
[1/11/2009],
[1/13/2009],
[1/15/2009]
FROM(SELECT[Date],
[Count],
MediaBuyer
FROM#t
) p PIVOT (SUM([Count])
FOR [Date]
IN ([1/7/2009], [1/9/2009], [1/11/2009], [1/13/2009], [1/15/2009])
) As pvt
I have one other column MediaBuyer which I cannot find a way to nest that inside here.
January 14, 2010 at 11:41 am
You're almos there.....
SELECT MediaBuyer,
[1/7/2009],
[1/9/2009],
[1/11/2009],
[1/13/2009],
[1/15/2009]
FROM (
SELECT [Date],
[Count],
MediaBuyer
FROM #t
) p
PIVOT (
SUM([Count])
FOR [Date] IN ([1/7/2009], [1/9/2009], [1/11/2009], [1/13/2009], [1/15/2009])
) As pvt
January 14, 2010 at 1:16 pm
Thanks John! I found an article on codeproject which helped me a lot. But thanks for your help too.
http://www.codeproject.com/KB/database/Pivot2Columns.aspx
Sid
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply