mssql 取數據指定條數(例:100-200條的數據)


方法1:臨時表 

select top 200 * into #aa from table order by time-- 將top m筆插入 臨時表 
set rowcount 100 
select * from #aa order by time desc 

--drop table #aa --刪除臨時表 

方法2:

1 select top 100 * from 
2 (select top 200 * from table order by time asc)  
3 order by time desc 

方法3: not in

1 select top 100 * from v_company where ( 
2 id not in 
3 (select top 100 id from v_company order by id asc) 
4 ) order by id asc 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM