select top 10 * from (select top 40 * from 表名 order by id)a order by id desc--orselect top 10 * from 表名 where id not in(select top 30 id from 表名 order by id) order by id
select top 10 * from tab where PKID>30 select * from tab where PKID between 31 and 40select 40 * from tab execpt select top 30 * from tab
参考: http://whx.tzgt.gov.cn/newOperate/html/3/33/331/11880.html其中的T-SQL你可以照抄。不过人家使用Linq to SQL,更方便地变化程序思路。
select top 10 * from (select top 40 * from 表名 order by id)a order by id desc
select a.* from (select top 40 * from tab) a left join (select top 30 * from tab) b on a.id=b.id where b.id is null
select top 10 * from (select top 40 * from 表名 order by id)a order by id desc--orselect top 10 * from 表名
where id not in(select top 30 id from 表名 order by id) order by id
http://whx.tzgt.gov.cn/newOperate/html/3/33/331/11880.html其中的T-SQL你可以照抄。不过人家使用Linq to SQL,更方便地变化程序思路。
(select top 40 * from tab) a left join (select top 30 * from tab) b
on a.id=b.id where b.id is null