Hello so I have a table as such in SQlite:
User | Group | Role
John Smith | A | admin
John Smith | B | user
Jane Doe | A
The excellent solution offered by @CPerkins has the potential drawback of losing information. For example, consider what would happen if the data for "Jack Brown" was presented in two rows:
Jack Brown | A | admin
Jack Brown | A | user
To ensure no information is lost, one could use GROUP_CONCAT instead of MAX:
SELECT User,
GROUP_CONCAT(CASE WHEN "group" == 'A' THEN role END) as A,
GROUP_CONCAT(CASE WHEN "group" == 'B' THEN role END) as B,
GROUP_CONCAT(CASE WHEN "group" == 'C' THEN role END) as C
FROM SO52961250 t
GROUP BY User;