Skip to content

Latest commit

 

History

History
10 lines (10 loc) · 467 Bytes

1158. Market Analysis I.md

File metadata and controls

10 lines (10 loc) · 467 Bytes

1158. Market Analysis I

Question Link

Solution

# Write your MySQL query statement below
select u.user_id buyer_id, u.join_date, if(a.orders_in_2019 is not null,a.orders_in_2019,0) orders_in_2019 from Users u left join (
  select buyer_id, count(distinct order_id) orders_in_2019 from Orders
  where order_date>='2019-01-01' and order_date<='2019-12-31' group by buyer_id
) a on u.user_id=a.buyer_id