首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

[请问]union或者union all之后的结果如何进行排序并且按照rowid查找

2012-09-14 
[请教]union或者union all之后的结果怎么进行排序并且按照rowid查找?[请教]union或者union all之后的结果

[请教]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 

热点排行