Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Pivot Static Columns for Group by Rows

$
0
0

I have some commonly alike problem but its different from dynamic pivot unpivot

Input Table
IDValue
Guid1Val1
Guid1Val2
Guid1Val3
Guid1val4
Guid2asd
Guid2asd
Guid2asd
Guid3test
Guid4Lee
Guid4Jack
Guid4Arnol
Guid4wan
Guid4Swin
Output Table
IDCol1Col2Col3Col4Col5
Guid1Val1Val2Val3val4NULL
Guid2asdasdasdNULLNULL
Guid3testNULLNULLNULLNULL
Guid4LeeJackArnolwanSwin

I have to group by my input rows based on ID & rotate them to fixed 5 column table if values are not there I have to fill with NULL.

Kindly let me know if you need more clarification on the problem

I'm looking for solution in Either SSIS or T-SQL.


Viewing all articles
Browse latest Browse all 12963

Trending Articles