应该是oracle版本的问题,在8i以前的版本,子查询或者视图中是不允许用order by子句的,早期的develop版本也是一样。

解决方案 »

  1.   

    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
      

  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
      

  3.   

    order by sum(b.price) desc)u,emp c where u.a1=c.empid and rownum<2 ;
    ????