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

[请教]union或者union all之后的结果怎么进行排序并且按照rowid查找?
[请教]union或者union all之后的结果怎么进行排序并且按照rowid查找?
在线关注。

------解决方案--------------------
SQL code
declare @rowid int set @rowid=2

select * from 
(
select * from a
union all
select * from b
) aa where rowid=2 order by 排序列

------解决方案--------------------
SQL code

-----------sql中没有rowid,oracle中才有的。
-----------sql中的行号是,row_number
select * from (select rowid=row_number() over(order by xh),* from(
select * from goal
union all
select * from goal )tmp)tmp2 where rowid=1