select * from (select * from (select zxbz,count(*)rs from dc_jhmy where 1=1 group by zxbz order by rs desc
union all
select 'hj' as zxbz,count(*)rs from dc_jhmy where 1=1)where rownum <= 100
SQL语句如上,我想实现除最后的union all 之前所有的记录先排序,然后在加上最后一条记录,可是 order by rs desc
放在现在的位置报错,命令未正确结束。
解决方法如下:利用临时表
select * from (select * from (select zxbz,count(*)rs from dc_jhmy where 1=1 group by zxbz order by rs desc)
union all
select 'hj' as zxbz,count(*)rs from dc_jhmy where 1=1)where rownum <= 100