How to write a query to convert colums into rows in sql?

Posted by Suneel161 under Sql Server on 4/5/2011 | Points: 10 | Views : 1220 | Status : [Member] | Replies : 2
Hi All.


i want a query for showing the columns in rows like,

RegularHours OTHours TrainingHours TrainingOT VacationHours
5,000 1,000 500 25 250



I want it to look like this:

XYZ ABC
5,000 RegularHours
1,000 OTHours
500 TrainingHours
25 TrainingOT
250 VacationHours




Responses

Posted by: Lalji_mer on: 4/5/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

show here good article will help you..

http://www.eggheadcafe.com/tutorials/aspnet/6b337a91-0565-4ed3-9039-864e70abee96/converting-rows-as-column.aspx

LP MER

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suneel161 on: 4/5/2011 [Member] Starter | Points: 25

Up
0
Down
Hi All.


i want a query for showing the columns in rows like,

f1 f2 f3....... f20 s1 s1 s3.......s20 w1 w2 w3.....20
A1 A2 A3.........A20 B1 B2 B3......... B20 C1 C2 C3.......C20

Result:
f1 A1
f2 A2
.
.
.
.
f20 A20
S1 B1
S2 B2
.
.
.
S20 B20

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response