SQL数据库 先从大到小排序 然后取10到15之间的数据。
SQL数据库 先从大到小排序 然后取10到15之间的数据????
[解决办法]
select *
from (
select *,rid = row_number() over (order by colname desc)
from tb
) temp
where rid between 10 and 15
order by rid
--SQL Server 2000
select top (5) *
from ( select top 15 * from 表 order by 排序列 desc ) as a
order by 排序列 desc
--SQL Server 2005,2008,2008R2,2012通用方法
select *
from (
select *,row_number() over (order by 排序列 desc) as id
from 表
) a
where id between 10 and 15
order by id
--SQL Server 2012
select * from 表 order by 排序列 desc OFFSET 10 ROW FETCH NEXT 5 ROWS ONLY