Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to implement the following scenario

change the following dataset
v1 1
v2 2
v3 3

to

v1 v2 v3
1 2 3


please help, i heard there is some pivot table thing, please share if there is any tutorial
Posted

if you just need the tutorial to implement SQL Pivot then

click here[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Feb-13 17:52pm    
That should be enough to understand this matter, a 5.
—SA
Hasham Ahmad 18-Feb-13 18:10pm    
thanks Sergey :)
Hi Friend,

Please find the below answer for your query.


SQL
CREATE TABLE #pvt 
(
na varchar(5),
id int
)
INSERT INTO #pvt (na,id) VALUES('v1',1),('v2',2),('v3',3)

SELECT * FROM #pvt 

SELECT v1 AS [V1],v2 AS [V2],v3 AS [V3] FROM
(
SELECT na,id  FROM #pvt 
)p
pivot 
(
min(id)
FOR na in (v1,v2,v3)
)as pvt
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900