select u.a1,u.a2,c.name from (select a1, -a2 a2, rownum r from (select a.empid a1,sum(-b.price) a2 from saledinsurance a,insurance b where a.insuranceid=b.insuranceid group by a.empid) group by a2,a1) u, emp c where u.a1=c.empid and r<2
select u.a1,u.a2,c.name from (select a1, -a2 a2, rownum r from (select a.empid a1,sum(-b.price) a2 from saledinsurance a,insurance b where a.insuranceid=b.insuranceid group by a.empid) group by a2,a1) u, emp c where u.a1=c.empid and r<2
order by sum(b.price) desc)u,emp c where u.a1=c.empid and rownum<2 ; ????
from (select a1, -a2 a2, rownum r
from (select a.empid a1,sum(-b.price) a2
from saledinsurance a,insurance b
where a.insuranceid=b.insuranceid
group by a.empid)
group by a2,a1) u, emp c
where u.a1=c.empid and r<2
from (select a1, -a2 a2, rownum r
from (select a.empid a1,sum(-b.price) a2
from saledinsurance a,insurance b
where a.insuranceid=b.insuranceid
group by a.empid)
group by a2,a1) u, emp c
where u.a1=c.empid and r<2
????