pennate 发表于 2016-11-7 03:32:19

SQL Server分页(查询某几条数据或某个区间内的几条数据)

  从person表中找出第10条到第15条记录:
  
  
  
  
  select * from
  (select pid,row_number() over(order by pid asc) rowno from person) as t1(pid,rowno)
  where rowno between 10 and 15
  
  主要用到了row_number()函数,这个函数是SQL Server里自己带的。
  
  具体思路是先从person表中找出符合条件的记录,对每条就编号(rowno),再限定编号(rowno)的范围。
页: [1]
查看完整版本: SQL Server分页(查询某几条数据或某个区间内的几条数据)