I have a table like this:
ipiresia | program |
---|---|
1 | 1 |
1 | 2 |
1 | 3 |
2 | 1 |
2 | 2 |
2 | 3 |
3 | 1 |
3 | 2 |
3 | 3 |
4 | 1 |
4 | 2 |
I want to make a query to transform the table like this:
ipiresia | program1 | program2 | program3 |
---|---|---|---|
1 | x | x | x |
2 | x | x | x |
3 | x | x | x |
4 | x | x |
I have used this query but it doesn't work:
SELECT ipiresia, (CASE program WHEN '1' THEN 'x' ELSE NULL) AS program1, (CASE program WHEN '2' THEN 'x' ELSE NULL) AS program2, (CASE program WHEN '3' THEN 'x' ELSE NULL) AS program3 FROM table GROUP BY ipiresia
Any help is appreciated.