I have a KVP Key value pair Table, Need sql to make it relational structure...!
Posted
by Muthuveerappan
on Stack Overflow
See other posts from Stack Overflow
or by Muthuveerappan
Published on 2010-03-20T10:33:29Z
Indexed on
2010/03/20
10:41 UTC
Read the original article
Hit count: 210
I have a KVP Table and the structure is ID, Key, Value and below are the sample values....
Table with values
ID , Key, Value
1 , STATUS, TRUE
1, AGE GROUP, 10
1, TRAVEL, Y
2 , STATUS, FALSE
2, AGE GROUP, 20
2, TRAVEL, N
I want these date to transform as below (Output)
ID , STATUS, AGE GROUP, TRAVEL
1, TRUE , 10, Y
2, FALSE, 20, N
I have read about crosstab/pivot - but not able to make a query which can give me the above output. The table structure cant be changed...! My bad.
Is there any way in sql, to make my output look like above ?
© Stack Overflow or respective owner