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.
Author |
Topic |
jake85
Starting Member
2 Posts |
Posted - 2012-01-17 : 15:02:04
|
hi, I need to create a dataset from a stored proc that works off the following table structure:Table: (ordered on A)A B C-- -- --0 1 Val10 2 Val20 3 Val31 1 Val41 2 Val51 3 Val6etc....Result Dataset format: (returns new columns D,E)A C D E -- -- -- -- 0 Val1 Val2 Val3 1 Val4 Val5 Val6etc...Hope this is clear as I'm new to sql and not sure how to illustrate my question. Basicly I need to get the three consecutive rows from the table together in one row.This is a real show stopper- any help on e how to do it would be greatly appreciated! |
|
X002548
Not Just a Number
15586 Posts |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-17 : 15:17:20
|
[code]SELECT A, [1] AS [C], [2] AS [D], [3] AS [E]FROM yourTablePIVOT( MAX(c) FOR b IN ([1],[2],[3])) P[/code] |
 |
|
jake85
Starting Member
2 Posts |
Posted - 2012-01-19 : 11:12:46
|
WOW! PIVOT works perfectly for my problem! Thank you so very much for your help sunitabeck!I'm such a noob I didn't even know PIVOT existed.@X002548 - well taken, your guide will help me for future posts - thanks! |
 |
|
|
|
|