Datatable select record grouped by id based on field data

For learnings have a starter help here: