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 ('空调', '洗衣机')
全部评论
相关推荐
10-30 18:20
第一拖拉机制造厂拖拉机学院 C++
牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学 点赞 评论 收藏
分享
点赞 评论 收藏
分享
基恩士成长空间 426人发布
查看11道真题和解析