如何用SQL查询第100-200的记录 ( 积分: 50 )

  • 主题发起人 主题发起人 Godfear
  • 开始时间 开始时间
G

Godfear

Unregistered / Unconfirmed
GUEST, unregistred user!
RT:如何用SQL查询第100条到200条的记录?
 
select&nbsp;top&nbsp;200&nbsp;*&nbsp;from&nbsp;table&nbsp;where&nbsp;index_field&nbsp;not&nbsp;in<br>(select&nbsp;top&nbsp;100&nbsp;*&nbsp;from&nbsp;table)
 
MSSQL&nbsp;&nbsp;select&nbsp;top&nbsp;100&nbsp;*&nbsp;from&nbsp;(select&nbsp;top&nbsp;200&nbsp;*&nbsp;from&nbsp;rs_da_grda)&nbsp;as&nbsp;A&nbsp;order&nbsp;by&nbsp;pcode<br>ORACLE<br>select&nbsp;*&nbsp;from&nbsp;(select&nbsp;rownum&nbsp;id,a.*&nbsp;from&nbsp;rs_da_grda&nbsp;a&nbsp;order&nbsp;by&nbsp;pcode)&nbsp;where&nbsp;id&nbsp;between&nbsp;100&nbsp;and&nbsp;200
 
多人接受答案了。
 
如果你是Sql&nbsp;Server&nbsp;2000:<br>Select&nbsp;<br> top&nbsp;100&nbsp;*&nbsp;<br>From&nbsp;<br>&nbsp;&nbsp;&nbsp;(<br> Select&nbsp;<br> top&nbsp;200&nbsp;*&nbsp;<br> From&nbsp;表名&nbsp;<br> order&nbsp;by&nbsp;字段名&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;as&nbsp;tableName<br><br>order&nbsp;by&nbsp;字段名&nbsp;desc<br><br>如果你是Sql&nbsp;Server&nbsp;2005:<br>Select&nbsp;*&nbsp;From&nbsp;<br>&nbsp;&nbsp;&nbsp;(Select&nbsp;<br> Row_Number()&nbsp;Over(order&nbsp;by&nbsp;字段名&nbsp;desc)&nbsp;as&nbsp;rowNum&nbsp;),字段1,字段2<br>&nbsp;&nbsp;&nbsp;&nbsp;From<br>&nbsp;&nbsp;&nbsp;&nbsp;表名&nbsp;as&nbsp;别名)<br>Where&nbsp;rowNum&nbsp;Between&nbsp;100&nbsp;and&nbsp;200<br>Order&nbsp;by&nbsp;字段名&nbsp;desc
 
后退
顶部