DEV Community

Timothy Soladoye
Timothy Soladoye

Posted on

List the data counted in mysql COUNT() GROUB BY GROUP_CONCAT()

We all know the regular group by and count

SELECT errors, COUNT(id) AS count AS ids 
FROM table GROUP BY errors;
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode
errors count ids
error1 4 2,3,4,5
error2 2 1,6
error3 1 8

Top comments (0)