题解 | #牛客的课程订单分析(六)#
牛客的课程订单分析(六)
https://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
自己还是比较习惯这种窗口函数的写法
select t.id ,t.is_group_buy,
case when is_group_buy = 'No' then t.client_name else NULL end
from (select tmp.*,
sum(case when status='completed' then 1 else 0 end) over(partition by user_id) as cnt
from (select a.* , b.name as client_name from order_info a left join
client b on a.client_id = b.id ) tmp
where status = 'completed' and date > '2025-10-15' and product_name in ('C++','Java','Python')
) t where t.cnt >= 2 order by id asc
查看6道真题和解析
360集团公司福利 406人发布