Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Trying To Pivot Data

Author  Topic 

gad
Starting Member

14 Posts

Posted - 2006-02-17 : 22:22:21
I have data in the following structure:

ID IDName 7DayPeriodStarting Count
10 HomeButton 1/2/2006 15075
20 HelpButton 1/2/2006 48699
30 SearchButton 1/2/2006 125991
40 AddButton 1/2/2006 7271
50 EditButton 1/2/2006 10969
60 MemButton 1/2/2006 4720
70 ProdButton 1/2/2006 3562

I'd like to pivot this by grouping on the 7DayPeriodStarting and display the IDName as columns with the corresponding counts per 7Day period. I know I can create multiple sub queries in the Select to do this, but the issue is that I have 250 unique ID names, and I'm wondering if there is a better way to pivot without creating 1 main query and 249 individual subqueries. Thanks for your help!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-17 : 22:37:14
If you are using SQL 2005, you can take a look at PIVOT
Or in SQL 2000, check out the pivot table in Sticky http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210

----------------------------------
'KH'

Time is always against us
Go to Top of Page

gad
Starting Member

14 Posts

Posted - 2006-02-19 : 16:15:36
Thanks much for pointing me to existing articles/topics. I shall check those prior to posting next time. Great site.
Go to Top of Page
   

- Advertisement -