You haven't specified your desired output. But if you're wanting a comma separated list by group you can do something like this answer from the below StackOverflow threads:
MySQL
SELECT t.group_id,
       GROUP_CONCAT(t.product_id) AS product_id_group
FROM [YOURTABLE] t
GROUP BY t.id, t.product_id;
MySQL Results as comma separated list
SQL Sever
SELECT group_id, product_id = 
    STUFF((SELECT ', ' + product_id
           FROM [YOURTABLE] t1
           WHERE t1.group_id = t2.group_id 
          FOR XML PATH('')), 1, 2, '')
FROM [YOURTABLE] t2
GROUP BY group_id
SQL Server : GROUP BY clause to get comma-separated values
This will return a result set like:
group_id    product_id
2           65, 50, 30, 60, 42
5           40, 42
6           30, 65, 60
7           90, 40