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 2005 Forums
 Transact-SQL (2005)
 Dymanic cross tab query

Author  Topic 

konark
Yak Posting Veteran

60 Posts

Posted - 2009-01-28 : 14:46:25
I have a weekly and monthly score table.

Week_score
------------
Student_ID week_id month_id Year_id score





Month_score
------------

Student_ID month_id Year_id score


Month_score is made by aggregating week_score table by using a table 'month_weeks' which contains

month_id No_of_weeks



Suppose today is June 2009. The required output is

student_id 2007_score 2008_score Jan_2009 Feb_09 Mar_09 APR_09 MAY_1stweek May_2ndweek May_3rd Week May_4thWeek.




Is this possible?

Chandragupta Mourya

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-28 : 14:47:31
Search for Dynamic pivot in forum.
Go to Top of Page

AvanthaSiriwardana
Yak Posting Veteran

78 Posts

Posted - 2009-01-29 : 01:53:37
you may have to use pivoting in SQL or try to use cube.

Avantha Siriwardana
Go to Top of Page
   

- Advertisement -