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 2008 Forums
 Transact-SQL (2008)
 row to column conversion

Author  Topic 

Mayur Dhumal
Starting Member

4 Posts

Posted - 2012-01-10 : 06:42:04
Hi guys,

I need help in the following:

i have tables given below,
ID TABLE
ID ID_SEQ
101 1
102 2
103 3
104 4
105 5


DESCRIPTION TABLE

ID_SEQ ID_SOC DESCRIPTION
1 10 ABC
1 20 DEF
1 30 GHI
1 40 JKL
1 50 MNO
2 10 ABC
2 20 DEF
2 30 GHI
2 40 JKL
2 50 MNO



VALUE TABLE

ID_SOC VALUE DATE TIME
10 100 01-01-2011 11:15
10 130 01-05-2011 12:00
10 160 13-08-2011 13:14
20 140 21-06-2-11 14:56
20 210 18-05-2011 20:13
30 250 17-12-2011 18:46
30 310 16-04-2011 09:34
40 450 23-04-2011 17:50
40 500 30-03-2011 16:32
50 760 01-04-2011 01:10
50 893 31-12-2011 17:34


& i need output to be displayed as



ID DESCRIPTION1 VALUE DATE TIME ID DESC2 VALUE DATE TIME
101 ABC 100 01-01-2011 11:15 101 DEF 210 18-05-2011 20:13
& SO ON FOR OTHER DESCRIPTION
102 SAME DATA FORMAT AS ABOVE
103
.


i.e I NEED DATA FOR SINGLE ID WITH MANY DIFFERENT DESCRIPTIONS & THEIR VALUES IN A SINGLE ROW AS SHOWN ABOVE.


plz help me with this problem to resolve

thanx

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-10 : 06:53:11
you need this

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Mayur Dhumal
Starting Member

4 Posts

Posted - 2012-01-10 : 07:02:44
hey vishakh16,

i m really getting confused with this.
can u simplify that example for the above case.
Go to Top of Page
   

- Advertisement -