I'm struggling to get all the terms involved in a GROUP BY
cleanly with MySQL. I currently use a query to bucket results based on month and year, then I create a comma separated list of values. The client is responsible for parsing the comma separated list.
This presents problems when the list gets too long and is truncated. It also appears messy, and I believe there might be a better way.
My query looks like:
SELECT
DATE(date_format(time_of_creation, '%Y:%m:01 00:00:00')) t0,
GROUP_CONCAT(TIMESTAMPDIFF(MINUTE, time_of_creation, t1))
FROM rr
GROUP BY
YEAR(t0),
MONTH(t0)
ORDER BY t0;
Is there a way in to get the elements that fall into each bucket without returning a large comma separated list?