读书人

[请问]union或者union all之后的结果如

发布时间: 2012-09-14 11:53:44 作者: rapoo

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

[解决办法]

SQL code
declare @rowid int set @rowid=2select * from (select * from aunion allselect * from b) aa where rowid=2 order by 排序列
[解决办法]
SQL code
-----------sql中没有rowid,oracle中才有的。-----------sql中的行号是,row_numberselect * from (select rowid=row_number() over(order by xh),* from(select * from goalunion allselect * from goal )tmp)tmp2 where rowid=1 

读书人网 >SQL Server

热点推荐