题解 | #牛客的课程订单分析(六)#
牛客的课程订单分析(六)
http://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
知识点
- 窗口函数和之前一样的
- 因为客户端id可能没有出现null值所以连接时用左连接连接client表
代码
select t.id, t.is_group_buy, c.name as client_name
from (
select id, is_group_buy, client_id,
count(*) over (partition by user_id) as cnt
from order_info
where date > '2025-10-15'
and product_name in ('C++', 'Python', 'Java')
and status = 'completed'
) as t
left join client as c
on c.id = t.client_id
where t.cnt >= 2
order by t.id