比如查某个部门购买的哪些商品是所有部门都没有买过的,这个需要嵌套select吗?
select distinct(item) from table where item not in (select distinct(item) from table where bumen<>'mouge') and bumen='mouge' -----------------不知道对不对......等待实践检验
select
*
from
something
where
name
in
(
select
name
from
something
group
by
name
having
COUNT
(*)>1)