Hello - I am hoping someone can assist with with Q6. The question being asked if to see only those existing posts where users are still active and to write a query with Inner join and have posts be the left table.
After looking at the question, and looking at the tables, I utilized posts.created_date to determine who is still active - I noticed that there were Null values in these dates and maybe made the incorrect assumption that meant that the user was no longer active.
I also wanted to see what the latest date was, so I used SELECT MAX(created_date) FROM posts; and found 2020-06-16 was the latest date. Based on those two assumptions, I wrote the following query:
SELECT posts.title, strftime(’%Y’, posts.created_date) AS ‘active’ FROM posts
JOIN users
ON posts.user_id = users.id
WHERE posts.created_date IS NOT NULL
ORDER BY posts.created_date DESC;
I came back with titles and dates for any user still posting which I thought was correct, but when I checked the hint, I was really confused. The hint states:
SELECT * FROM ____
INNER JOIN users
ON posts.____ = users._____;
When I filled it in like this, I just got a list of user IDs that are numbered from 1 - 200 in ASC order:
SELECT * FROM posts
INNER JOIN users
ON posts.user_id = users.id;
That didn’t seem right to me, so I am very confused.
Can someone tell me why my query is wrong and why the hint query is right? Thanks!