select top 40 * from (select top 500 * from tb)tb where not exists(select top 21 * from tb)
select top 20 * from (500条的语句生成的记录集) x where id>(select max(id) from (select top 20 id from (500条的语句生成的记录集) y)m) 我这里假设你的500条的记录集以id排序顺序取出.如果以其它条件,则写法相似。 比如 500条的语句是 select top 500 *,(getAmount-sendAmount) dAmount from tb where state=1 order by dAmount那么上面的语句,将所有的 id改为damount.
select * from (select top 40 * from 500条临时表)tb where id not in (select top 21 id from 500条临时表)
(500条的语句生成的记录集) x
where id>(select max(id) from (select top 20 id from (500条的语句生成的记录集) y)m)
我这里假设你的500条的记录集以id排序顺序取出.如果以其它条件,则写法相似。
比如
500条的语句是
select top 500 *,(getAmount-sendAmount) dAmount from tb where state=1 order by dAmount那么上面的语句,将所有的 id改为damount.
select * from (select top 40 * from 500条临时表)tb where id not in (select top 21 id from 500条临时表)