Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple values into separate columns by its unique id field

Status
Not open for further replies.

ciarra41

Technical User
Sep 11, 2006
116
US
old table:
idnum values
5548 2s1dd
5548 35dd6
5548 4548p
5584 22de1

New table or sql:
idnum value1 value2 value3 value4
5548 2s1dd 35dd6 4548p 22de1
 
SELECT * FROM (SELECT idnum,value FROM old_table) x
PIVOT (min(value) FOR value IN ([1],[2],[3],[4])) y

just extend the 1,2,3,4 to cater for how many there could be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top