1

I have the following result

Student Form ID  | Result
-----------------------------
12               | PASSED
131              | PASSED
131              | RESIT
144              | FAIL
23               | NA

Ideally I want where the ID is the same eg 131. To group the results so ID Result

Student Form ID  | Result
--------------------------------
131              | PASSED, RESIT

When I use group by, it isn't giving me the desired output, I'm obviously doing it wrong. Please could I have some guidance on how to achieve my desired result, i.e. where the ID is the same, the results should be grouped on one row.

1 Answers1

0

You can use aggregation is PostgreSQL: array_agg() or json_agg()

select student_form_id, array_agg(result) from your_table group by student_form_id;
Gaurav Neema
  • 146
  • 1
  • 1
  • 12