oracle group by rollup 排序问题
需要按第一行倒序排列,需要达到的效果是第一行为5,4,3,2,1,合计selectdecode(GROUPING(r),1,'合计',r)r,SUM(r2)r2from(...
需要按第一行倒序排列,需要达到的效果是第一行为5,4,3,2,1,合计
select decode(GROUPING(r),1,'合计',r) r, SUM(r2) r2
from (select rownum r,rownum+1 r2
from dual connect by rownum<=5)
GROUP BY ROLLUP((r,r2))
--order by r desc 展开
select decode(GROUPING(r),1,'合计',r) r, SUM(r2) r2
from (select rownum r,rownum+1 r2
from dual connect by rownum<=5)
GROUP BY ROLLUP((r,r2))
--order by r desc 展开
1个回答
2015-07-30
展开全部
前面不变,后面加如下order by :
order by to_number(decode(r, '合计', null,r)) desc nulls last
order by to_number(decode(r, '合计', null,r)) desc nulls last
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询