当前位置: 代码迷 >> Oracle开发 >> 能不能按照SUM后的值来进行排序解决办法
  详细解决方案

能不能按照SUM后的值来进行排序解决办法

热度:320   发布时间:2016-04-24 08:03:42.0
能不能按照SUM后的值来进行排序
请教用下面的语句取出来的值,能不能按照求和后的sum_eval的值来进行排序?

select sum(sum_eval),s_i_code1,s_i_name1 from TMP_REP_3 t
where ROWNUM<3
group by s_i_code1,s_i_name1 

执行后的结果如下:
sum(sum_eval) s_i_code1 s_i_name1
24637023.34 801070 机械设备
15002968.82 801200 商业贸易
5712000 801100 信息设备

------解决方案--------------------
select * from 
(
select sum(sum_eval) as sum_eval,s_i_code1,s_i_name1 from TMP_REP_3 t
group by s_i_code1,s_i_name1
order by sum(sum_eval)
)
where rownum<3
------解决方案--------------------
order by sum(sum_eval)
------解决方案--------------------
SQL code
select sum(sum_eval),s_i_code1,s_i_name1 from TMP_REP_3 twhere ROWNUM<3group by s_i_code1,s_i_name1  order by sum(sum_eval) desc
------解决方案--------------------
SQL code
order by sum(sum_eval)
  相关解决方案