题解 | #牛客的课程订单分析(六)#

牛客的课程订单分析(六)

http://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f

思路:
①先找出符合要求的user_id
select user_id from order_info
where date > "2025-10-15"
and status = "completed"
and product_name in ("C++","Java","Python")
GROUP by user_id
having COUNT(id) > 1

②从符合要求的user_id里,连接order_info和client表。

select a.id,a.is_group_buy,c.name
from order_info as a
LEFT JOIN client as c
on a.client_id=c.id
where user_id in(
select user_id from order_info
where date > "2025-10-15"
and status = "completed"
and product_name in ("C++","Java","Python")
GROUP by user_id
having COUNT(id) > 1 )
and date > "2025-10-15"
and status = "completed"
and product_name in ("C++","Java","Python")

全部评论
请问为什么主查询中需要再筛选一遍and date > "2025-10-15" and status = "completed" and product_name in ("C++","Java","Python"),子查询里不是已经筛过了吗,它返回的值不应该是满足这些条件的吗,但是我删掉之后结果不对
点赞 回复 分享
发布于 2024-05-23 19:07 英国

相关推荐

12-15 14:16
门头沟学院 Java
回家当保安:发offer的时候会背调学信网,最好不要这样。 “27届 ”和“28届以下 ”公司招聘的预期是不一样的。
实习简历求拷打
点赞 评论 收藏
分享
评论
5
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务