查询订单表里有且仅购买空调和洗衣机的订单数with a as (selectorderid,count(distinct category)fromtbl_ordergroup by orderidhaving count(distinct category) = 2)selectcount(distinct a.orderid)from aleft join tbl_order as o on a.orderid = o.orderidand category in ('空调', '洗衣机')