So I am working on the bonus practice for joining multiple tables. I have come to the question about the WELP reviews and I have been staring at it forever I feel like, I’m fairly new to Codecademy so was hesitant to ask for help but seems like my best option. I’m sure it’s something small I’m missing so please no judgement :).
So the following is the question and following that is the query I’m trying to use. So I’ve studied the tables multiple times but when I run the basic query with the WITH and STRFTIME but it returns no results. Like I said, I’m sure it’s something minor that I’m overlooking but I could really use some advice. Thanks so much .
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.)
WITH reviews_2020 AS (
SELECT *
FROM reviews
WHERE strftime("%Y", review_date) = ‘2020’
);
Using WITH is one way of creating a temporary table to work with but I can’t see what you actually do with it, you seem to be missing some code. You might want to quickly review how to use WITH. The instructions mention joining it to something else, have you tried that bit (is this all the code for this query?).
I came here to search for a fix to my errors, and I was missing the apostrophes for the date.
But I believe this is missing the JOIN clause to complete the full requirement. Still unsure if there is a difference between using INNER JOIN or simply JOIN, but seems to give equal results.
WITH reviews_2020 AS (
SELECT *
FROM reviews
WHERE strftime("%Y", review_date) = '2020'
)
SELECT *
FROM reviews_2020
JOIN places
ON places.id = reviews_2020.place_id;
Is the JOIN clause necessary for any reason other than the prompt asked us to include it?
If not, isn’t the most efficient way to write this code the following? If the below code is different than the code you provided, can you elaborate on what is different?
SELECT *
FROM reviews
WHERE strftime('%Y', review_date) = '2020'