Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Good Morning Everyone,I'm trying to convert rows to columns and can't figure out what's best way to do it.This is what i have right nowID Jan Feb March .......Dec1 20 25 55 2 34 53 03This is what i wantID Month Value1 1 201 2 252 1 342 2 53Please help
blindman
Master Smack Fu Yak Hacker
2365 Posts
Posted - 2006-05-01 : 11:25:34
Actually, you are trying to convert columns to rows...
select ID, 1, Jan as Valuefrom [YourTable]UNIONselect ID, 2, Feb as Valuefrom [YourTable]UNION...select ID, 12, Dec as Valuefrom [YourTable]