Multiple Tables with Reddit #9

Can anyone post the answer for #9? https://www.codecademy.com/paths/analyze-data-with-sql/tracks/analyze-data-sql-join-data/modules/analyze-data-sql-practice-joins/projects/sql-multiple-tables-with-reddit

The hint isn’t enough for me. I don’t understand what it means when they say utilize an INNER JOIN to join this table with the subreddits table, with subreddits as the left table. Would that not be a LEFT JOIN?

Yeah, that’s confusing. With an inner join, it doesn’t matter which is right or left because only what it is in common is selected. I’d ignore the left part and just do a normal inner join. I do have the solution if you are absolutely stuck.

Thanks. I think I do need the solution. I can’t see the tables because my answer is wrong so I can’t see the column names to know what to put in the query.

Gotcha. If you comment out (ctrl+/) the query with the error in it, you’ll be able to see the columns in your previous queries. But here’s my solution.

SELECT DISTINCT subreddits.name, posts.title, MAX(posts.score) FROM posts INNER JOIN subreddits ON subreddits.id = posts.subreddit_id GROUP BY 1;

1 Like