56,687
社区成员
发帖
与我相关
我的任务
分享
select c.sid
from parts as p, catalog as c
where p.pid=c.pid
group by c.sid
having count(*)=sum(case when p.color='red' then 1 else 0 end);
select c.sid, p.color, c.cost
from parts p , catalog c
where p.pid=c.pid
and (p.color='red' or p.color='green')
group by c.sid, p.color
having count(color)=1
order by c.cost desc;
select sid, count(*) count
from catalog
group by sid
order by count desc;