Welp.sqlite

FROM THE WELP EXERCISE, NO 8
Sometimes on Welp, there are some old reviews that aren’t useful anymore.

Write a query using the WITH clause to select all the reviews that happened in 2020. JOIN the places to your WITH query to see a log of all reviews from 2020.

(This will use the WITH clause as well as the strftime() function. See if you can use Google to dig up some information about the function before take a look at the hint.)

So to achieve the result I used this query :
SELECT * FROM
reviews
JOIN places
ON reviews.place_id = places.id
WHERE strftime ("%Y", review_date) = ‘2020’
LIMIT 10;

The results came out to what was demanded in the question 8. But then I tried alternate to verify because that was in the Hint section.
Issue is, this alternate query doesn’t return any result. What could be the issue with this ?
Would like to understand the if the first query’s result is same as the alternate query ?
Alternate -
WITH reviews2020 AS (
SELECT *
FROM reviews
WHERE strftime("%Y", review_date) = ‘2020’
)
SELECT
FROM reviews2020
JOIN places
ON reviews.place_id = places.id;

The result looks like this :

Is this on the DS path? Do you have a link to the lesson?

Looking at your 2nd query, you’re missing something in the SELECT statement and your JOIN clause needs some tweaking.

1 Like

https://www.codecademy.com/paths/analyze-data-with-sql/tracks/analyze-data-sql-join-data/modules/analyze-data-sql-practice-joins/projects/sql-welp