当前位置: 代码迷 >> Sql Server >> 语句中TOP 30可以获得排序的前30个条数据,怎么得到排在中间的比如60-90的
  详细解决方案

语句中TOP 30可以获得排序的前30个条数据,怎么得到排在中间的比如60-90的

热度:84   发布时间:2016-04-27 19:55:35.0
语句中TOP 30可以获得排序的前30个条数据,如何得到排在中间的比如60-90的?
比如
select   top   30   *   from   table   ORDER   BY   id   DESC
获得前30个数据项。
如何的到排序在60-90的30个数据项?

------解决方案--------------------
select top 30 * from (select top 60 * from table ORDER BY id) a order by id DESC
------解决方案--------------------
select top 30 * from table where id not in (select top 60 id from table ORDER BY id) order by id DESC
------解决方案--------------------
select top 30 * from (select top 60 * from table ORDER BY id) a order by id DESC

------解决方案--------------------
select top 31 * from
(select top 90 * from table order by id)
a order by a.id DESC

------解决方案--------------------
冒牌邹的...有些问题.

select top 30 * from table where id not in (select top 60 id from table ORDER BY id) order by id

如果是not in 就别 desc排序 ...
  相关解决方案