日期:2014-05-17  浏览次数:21182 次

能不能按照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 t
where ROWNUM<3
group by s_i_code1,s_i_name1  
order by sum(sum_eval) desc

------解决方案--------------------
SQL code
order by sum(sum_eval)