--16.查找每个采购员和每个供应商签订的合同的总金额,要求显示采购员姓名、供应商名称、和签订合同的总金额
select a.ename, c.sname, sum(b.cgmoney)
from employee a, stock b, supplier c
where a.etype=2 and a.eid=b.eid and b.sid=c.sid
group by a.ename, c.sname
--15.请使用左连接完成以下查询:查找每一个销售人员销售的商品的详细信息,要求显示销售人员姓名、销售单ID、客户姓名、商品名称、销售数量、和销售单价
select a.ename, b.said, d.cuname, e.cname, c.sdnumber, c.sdprice
from employee a
left outer join sale b on a.eid=b.eid
left outer join saledetail c on b.said=c.said
left outer join customer d on b.cuid=d.cuid
left outer join commodity e on e.cid=c.cid
where a.etype=3
order by b.said
--14.查找在2006年各个客户购买商品的总金额,要求结果按照购买商品的总金额降序排序
select b.cuid,sum(samoney)
from sale a,customer b
where a.cuid=b.cuid and year(sadate)=2006
group by b.cuid
order by sum(samoney)desc
--13.查找没有供应任何一类商品的供应商的名字
select sname
from supplier a
where not exists
( select a.sid from supplying b
where a.sid=b.sid)