So, let's say I want to select the identifier of all my blog posts and then the number of comments associated with this blog post, how can I use GROUP BY or ORDER BY so that the list returned is in the order of the number of comments per post?
Do I have this query that returns data, but not in the order I want? Changing a group makes no difference:
SELECT p.ID, count(c.comment_ID)
FROM wp_posts p, wp_comments c
WHERE p.ID = c.comment_post_ID
GROUP BY c.comment_post_ID;
source
share