Maison > base de données > tutoriel mysql > 写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Libérer: 2016-06-07 15:34:01
original
1681 Les gens l'ont consulté

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>
Copier après la connexion
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal