题解 | #牛客的课程订单分析(四)#
牛客的课程订单分析(四)
http://www.nowcoder.com/practice/c93d2079282f4943a3771ca6fd081c23
先将满足条件的UID选出来,然后根据uid选出最小日期,最后count出现的次数
SELECT user_id,min(date) as fisrt_buy_date,
count(case when product_name in("C++","Java","Python") then user_id else null end)as cnt
from order_info
where user_id in(
select user_id
from order_info
where `date`>"2025-10-15" and `status`="completed"
group by user_id
having count(case when product_name in("C++","Java","Python") then user_id else null end)>=2) and `date`>"2025-10-15" and `status`="completed"
GROUP by user_id
order by user_id