How do I group items separated by a 0 in a column using mysql?
WITH 
cte1 AS
(
SELECT shelf_id, remaining, SUM(remaining = 0) OVER (ORDER BY id) group_num
FROM test
)
SELECT GROUP_CONCAT(shelf_id) shelf_id,
       GROUP_CONCAT(remaining) remaining,
       SUM(remaining) total
FROM cte1
WHERE remaining != 0
GROUP BY group_num;


fiddle