Hi, could you fix my understanding? The code below is the eight task of the Joining Multiple Tables exercises, Multible Tables With Reddit. Link at end.
In my eyes, the SELECT function for (1) ‘subreddit,name’, and (2) max(posts.score) are distinct. So, I would think the result would comprise the alphabetically-first names within the GROUP BY function and the highest scores within the GROUP BY function.
However, the query returns the (1) name of the highest score post, and (2) the highest score. I.e., the alphabetically first name is not returned, and the query sorts for the name of the highest score. How does this work? Am I right in that this has to do with the GROUP BY function? thanks!
SELECT posts.title, subreddits.name AS 'subreddit_name', MAX(posts.score) AS 'highest_score' FROM posts INNER JOIN subreddits ON posts.subreddit_id = subreddits.id GROUP BY subreddits.id;