本题目要求编写Select语句,在SPJ数据库中,统计每个供应商的零件供应量总和。
要求:仅对那些每次供应零件的数量都在100以上(含100)的供应商进行统计。
如:供应商s2 供应工程项目j5 的p3零件数量为50,则不统计供应商s2
select a.sno as 供应商号,sname as 供应商,sum(qty) as 供应总量
from spj a,s
where a.sno=s.sno and not exists(
select distinct sno
from spj b
where qty<100 and sno=a.sno
)
group by a.sno,sname;
希望能帮助到大家
spj-查询比p6零件供应数量都高的零件 (10分)
select distinct pno
from spj a
where pno not in(
select pno
from spj b
where b.qty<=(
select max(qty)
from spj
where pno='p6'
)
);