Home > Database > Mysql Tutorial > 写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增

写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:34:01
Original
1683 people have browsed it

http://www.cnblogs.com/tangself/archive/2010/09/29/1838234.html 这位园友有讲过,可以看一下,简单说,对于这个题目,用row_number可以写成这样: -- 园友文章中的写法,这也是微软官方文档里的写法 WITH B AS ( SELECT * ,ROW_NUMBER() OVER ( ORDER BY

http://www.cnblogs.com/tangself/archive/2010/09/29/1838234.html

这位园友有讲过,可以看一下,简单说,对于这个题目,用row_number可以写成这样:

<span>--</span><span>园友文章中的写法,这也是微软官方文档里的写法</span><span><br></span><span>WITH</span> B <span>AS</span> (<br>    <span>SELECT</span> <span>*</span>,ROW_NUMBER() <span>OVER</span>(<span>ORDER</span> <span>BY</span> ID <span>ASC</span>) <span>AS</span> ROW_NUM<br>    <span>FROM</span> A <span>WITH</span>(NOLOCK)<br>)<br><span>SELECT</span> <span>*</span> <br><span>FROM</span> B <span>WITH</span>(NOLOCK)<br><span>WHERE</span> ROW_NUM <span>BETWEEN</span> <span>31</span> <span>AND</span> <span>40</span><br><span><br></span><span>--</span><span>我一般这么写</span><span><br></span><span>SELECT</span> <span>*</span> <span>FROM</span> (<br>    <span>SELECT</span> <span>*</span>,ROW_NUMBER() <span>OVER</span>(<span>ORDER</span> <span>BY</span> ID <span>ASC</span>) <span>AS</span> ROW_NUM<br>    <span>FROM</span> A <span>WITH</span>(NOLOCK)<br>) B <br><span>WHERE</span> ROW_NUM <span>BETWEEN</span> <span>31</span> <span>AND</span> <span>40</span>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template