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
 General SQL Server Forums
 New to SQL Server Programming
 Please Help me in Crosstab

Author  Topic 

rajeevalochan
Starting Member

1 Post

Posted - 2007-06-18 : 02:22:05
Hi i am new to crosstab feature.i want a crosstab dynamically with this below table please help me .Thanks in advance.

Table :-

id name costtype month&year amount

1 a1 Bcost 9/2005 300
2 a1 Ecost 9/2005 200
3 a1 Acost 9/2005 100
4 a2 Bcost 10/2005 150
5 a2 ECost 10/2005 100
6 a2 Acost 10/2005 150
7 a3 Bcost 11/2005 150
8 a3 ECost 11/2005 100
9 a3 Acost 11/2005 150



I want result table like this :-

ID Name Cost_Type 9/2005 10/2005 11/2005

1 a1 Bcost 300 -
2 a1 Ecost 200 -
3 a1 Acost 100 -
4 a2 Bcost - 150
5 a2 ECost - 100
6 a2 Acost - 150
7 a3 Bcost - - 150
8 a3 ECost - - 100
9 a3 Acost - - 150


I want above result Please Give me your help.

Thanks in advance,
Rajeev

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-18 : 02:23:25
see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6216


KH

Go to Top of Page
   

- Advertisement -