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
 SQL Server Development (2000)
 Field Name

Author  Topic 

MattieBala69
Starting Member

30 Posts

Posted - 2005-09-29 : 10:15:34
Hey ,
Lets say i have a table A which looks like this
Name Month Year hours
Chuck Nov 4 160
Chuck Dec 4 80
Chuck Jan 5 90
Chuck Apr 5 45
Kelly Nov 4 80
Kelly Dec 4 80
Kelly Jan 5 60
Kelly Feb 5 35
Don Jan 5 30
Don Feb 5 25
Don Mar 5 25
Don Apr 5 25

What i need is this is where i am lost . I have no idea how to make the data of one particular field in TABLE A to become field name in the select statement. The output should look like this

Name 04-Nov 04-Dec 05-Jan 05-Feb 05-Mar 05-Apr
Chuck 160 80 90 45
Kelly 80 80 60 35
Don 30 25 25 25

GTotal 240 160 180 60 25 70

Thank you,
Mattie

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-29 : 10:17:59
Cross tab?
http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Otherwise refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -