We all know the regular group by and count
SELECT errors, COUNT(id) AS count AS ids
FROM table GROUP BY errors;
What if you want to see the ids that made up the count you have?
GROUP_CONCAT() will do that for you!
SELECT errors, COUNT(id) AS count, GROUP_CONCAT(id) AS ids
FROM table GROUP BY errors;
errors | count | ids |
---|---|---|
error1 | 4 | 2,3,4,5 |
error2 | 2 | 1,6 |
error3 | 1 | 8 |
Top comments (0)