select at.typeName "事故类型", count(at.typeName) "事故次数", sum(au.deathCount) "死亡人数"
from acciedntType at, accident a, acciedntUser au
where at.id(+) = a.atypeid and a.aID (+) = au.aID
group by at.typeName
from acciedntType at, accident a, acciedntUser au
where at.id(+) = a.atypeid and a.aID (+) = au.aID
group by at.typeName
select at.typeName "事故类型", nvl(count(at.typeName), 0) "事故次数", nvl(sum(au.deathCount), 0) "死亡人数"
from acciedntType at, accident a, acciedntUser au
where at.id(+) = a.atypeid and a.aID (+) = au.aID
group by at.typeName;
from acciedntType a,
(select atypeid,count(*) n,sum(dc) dcc from acciednt b ,
(select aID,sum(deathCount) dc from acciedntUser) c
where b.aID=c.aID) d
where a.id=d.atypeid(+);
select at.typeName,a.aname,user.deathfrom accident a, acciedntType at,(select aID,sum(deathCount) death from acciedntUser group by aID) userwhere user.aID=a.aID and a.atypeid=b.id
)group by typeName
:(select a.typeName,nvl(d.n,0) sgcs,nvl(d.dcc,0) swrs
from acciedntType a,
(select atypeid,count(*) n,sum(dc) dcc from acciednt b ,
(select aID,sum(deathCount) dc from acciedntUser group by aID) c
where b.aID=c.aID group by atypeid) d
where a.id=d.atypeid(+);
------------------------------------------------------
不懂。楼主数据不就是要的到
3.人员死亡表(acciedntUser)uid aID(事故ID) deathCount(死亡人数)
1 1 5
2 3 20
3 3 5
4 1 5这样算重复了吗?事故类型 事故次数 死亡人数 交通事故 2 10
设备事故 2 25
环境事故 0 0
火灾事故 0 0
其他事故 0 0