Code Challenge 4 || SQL
Code Challenge 4 || SQL
We’ve used a?WITH?statement to create two temporary tables:
WITH january AS (
SELECT *
FROM plays
WHERE strftime("%m", play_date) = '01'
),
february AS (
SELECT *
FROM plays
WHERE strftime("%m", play_date) = '02'
),
Use a left join to combine?january?and?februaryon?user_id?and select?user_id?from?january.?
Add the following?WHERE?statement to find which users played songs in January, but not February:
WHERE february.user_id IS NULL
The solution :
SELECT january.user_id
FROM january
LEFT JOIN february
ON february.user_id = january.user_id
WHERE february.user_id IS NULL;