That's exactly what I am trying right now! 🙂
I got this so far:
SELECT col1,
col2,
CASE col4
WHEN 1 THEN col3
ELSE NULL
END AS col3_1,
CASE col4
WHEN 2 THEN col3
ELSE NULL
END AS col3_2,
CASE col4
WHEN 3 THEN col3
ELSE NULL
END AS col3_3
FROM table1
GROUP BY col1,
col2
However, when I run this I get the following errors:
Msg 8120, Level 16, State 1, Line 1
Column col3 is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 1
Column col4 is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
I'm working on it, but if you have the solution, please don't hesitate to post it. Thanks for your input by the way.