I have a dataset that looks like this:
id | test_id
---+--------
1  | a
1  | b
1  | u 
2  | a 
2  | u 
3  | a 
3  | b 
3  | u
And I would like to roll it up into a new table such that the test_id's are the column names (along with id) and the rows are either 1 or 0s depending if the test was given to that id, like so
id | a | b | u
---+---+---+--
1  | 1 | 1 | 1
2  | 1 | 0 | 1
3  | 1 | 1 | 1
Is there a way in Postgres that I can rearrange the table such as this?
 
     
    