Code Challenge 4 || SQL

Code Challenge 4 || SQL

Code Challenge 4 || SQL

We’ve used a?WITH?statement to create two temporary tables:

  • january?contains all song plays from January 2017
  • february?contains all song plays from February 2017


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;
         

要查看或添加评论,请登录

Ahmed Khaleel的更多文章

社区洞察

其他会员也浏览了