正确的:(排好顺序,再取出10列)
select * from ( select SJ.SJZLMC,nvl(RZL.RZL,0) RZL,nvl(sj.total,0) total from SA.SJJK_SJZL SJ
left outer join SA.SJJK_RZL RZL ON RZL.SJZLNO=SJ.SJZLNO AND RZL.ZLRQ=trunc(sysdate)-1
order by RZL.RZL desc ) where ROWNUM <= 10
错误的(取出10列数据再排序)
select SJ.SJZLMC,nvl(RZL.RZL,0) RZL,nvl(sj.total,0) total from SA.SJJK_SJZL SJ
left outer join SA.SJJK_RZL RZL ON RZL.SJZLNO=SJ.SJZLNO AND RZL.ZLRQ=trunc(sysdate)-1
where ROWNUM <= 10
order by RZL.RZL desc