有三个表的union all联合查询,(ID肯定有重复)select * from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb--我想对其进行分页,排序字段为RANK(有重复),排序规则为desc,请问该如何解决排序字段有重复的问题(注:没有一个字段是唯一的)?--如果排序字段RANK为唯一的话,sql我是这样写的,这样可以实现--第一页
select top 10 * from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb order by tb.RANK desc--其他页
select top 10 * from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb where RANK<(select min(RANK) from (select top 10*(第几页-1) RANK from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb order by RANK desc) b) order by RANK desc 排序字段为RANK(有重复),排序规则为desc,请问该如何解决排序字段有重复的问题(注:没有一个字段是唯一的)?
select top 10 * from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb order by tb.RANK desc--其他页
select top 10 * from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb where RANK<(select min(RANK) from (select top 10*(第几页-1) RANK from ( select ID,name,RANK from a union all select ID,name,RANK from b union all select ID,name,RANK from c) as tb order by RANK desc) b) order by RANK desc 排序字段为RANK(有重复),排序规则为desc,请问该如何解决排序字段有重复的问题(注:没有一个字段是唯一的)?
解决方案 »
- as
- 外网连接SQL SERVER数据库问题求助!!!
- 数据库-常规-可用空间 0.00M,大小为 4317.81M,但是我的数据文件是设置默认的自动增长的,难道有什么地方要重新设置?
- 为将要出世的儿子,未来的花朵,姓名征集活动
- 为什么 "sql analysis services 启动后有重启了"
- ntext字段中的内容,我如何用关键字去模糊查询?
- WIN2000 PRO下征求个SQL SERVER2000安装的方案,请大家帮忙!在线等!
- sql server有在win2000 profesional上可以安装的版本吗?
- sql server中,什么类型存储的数据量最大?是用来存文本的!
- 怎样定义一个全局变量.
- 求助覆盖表一部分列的方法
- Sql2008安装报错
如果还存在第一个字段重复,那继续按第二个字段排序