SQL 81) 牛客的课程订单分析(五)
牛客的课程订单分析(六)
http://www.nowcoder.com/questionTerminal/c5736983c322483e9f269dd23bdf2f6f
解法和前几题类似
需要注意的点
表连接时需要使用left join来左连结order_info表,因为client_id = 0这个数据在client表里是不存在的,会在连结时被去掉
select o.id, o.is_group_buy ,
case when o.is_group_buy = 'No'then c.name else NULL end
from order_info as o left join client as c
on o.client_id = c.id
where user_id in
(select user_id
from order_info
where date >'2025-10-15'
and product_name in ('C++','Java','Python')
and status = 'completed'
group by user_id
having count(id) > 1)
and o.date > '2025-10-15'
and o.product_name in ('C++','Java','Python')
and o.status = 'completed'
order by o.id ascSQL 文章被收录于专栏
SQL
查看16道真题和解析