Reputation: 458
How would you convert a field that is store as multiple rows into columns?
Current data:
COL1 COL2 COL3
----------------
TEST 30 NY
TEST 30 CA
TEST2 10 TN
TEST2 10 TX
I would like the output to be :
COL1 COL2 COL3 COL4
------------------------
TEST 30 NY CA
TEST2 10 TN TX
Upvotes: 1
Views: 56
Reputation: 2063
based on your sample data, you can try this. no need to use pivot.
SELECT col1,
col2,
MIN(col3) col3,
MAX(col3) col4
FROM table
GROUP BY col1,
col2
Upvotes: 1