sql 有且仅有
查询订单表里有且仅购买空调和洗衣机的订单数
with a as (
select
orderid,
count(distinct category)
from
tbl_order
group by orderid
having count(distinct category) = 2
)
select
count(distinct a.orderid)
from a
left join tbl_order as o on a.orderid = o.orderid
and category in ('空调', '洗衣机')
with a as (
select
orderid,
count(distinct category)
from
tbl_order
group by orderid
having count(distinct category) = 2
)
select
count(distinct a.orderid)
from a
left join tbl_order as o on a.orderid = o.orderid
and category in ('空调', '洗衣机')
全部评论
相关推荐
点赞 评论 收藏
分享
![](https://static.nowcoder.com/fe/file/oss/1716965564844UEBJN.png)
![](https://static.nowcoder.com/fe/file/oss/1716965585666UBBME.png)
腾讯
| 校招
| 超多精选岗位
点赞 评论 收藏
分享
01-23 19:12
门头沟学院 Java 点赞 评论 收藏
分享