I need to perform a query to get the candies that are most liked by kids and here's what I've got:
SELECT COUNT(*) as counts,candies.name
FROM candies
INNER JOIN kid_candy ON kid_candy.candy_id = candies.id
INNER JOIN kids ON kids.id = kid_candy.kid_id
GROUP BY candies.name
which would return:
counts | name
--------+---------
3 | snowbear
3 | whiterabbit
2 | lollipop
All I want to see would be just
counts | name
--------+---------
3 | snowbear
3 | whiterabbit
So what should my query be?