Solved MS SQL Cross Tab (1 Viewer)

Rakesh935

Registered User.
Local time
Tomorrow, 03:50
Joined
Oct 14, 2012
Messages
71
Hi Guys,

Need your help in cross tab the below table:

Note: I would be doing in MS SQL Environment.

ID Tel1 Tel2
123 1111 3333
456 2222 4444

into

Id Tel_ID TelNo
123 Tel1 1111
123 Tel2 3333
456 Tel1 2222
456 Tel2 4444

Thanks guys for looking into this and providing solutions (in advance).


Regards,
Rakesh
 

June7

AWF VIP
Local time
Today, 14:20
Joined
Mar 9, 2014
Messages
5,470
The second table is a UNION of the first.

SELECT ID, "Tel1" AS Tel_ID, Tel1 AS TelNo FROM tablename
UNION SELECT ID, "Tel2", Tel2 FROM tablename;

The first table could be a CROSSTAB result from the second table.
 
Last edited:

Rakesh935

Registered User.
Local time
Tomorrow, 03:50
Joined
Oct 14, 2012
Messages
71
Thanks June....

It works...

My bad I didnt think about union...

Have a great time ahead.

Cheers
Rakesh
 

Users who are viewing this thread

Top Bottom