group by won't help
I don't think this can be done using sql

it should be done after the record is feteched, while adding the output to the report

I don't think this should be a problem as long as you are just displaying and not storing them in that way.