zoukankan      html  css  js  c++  java
  • SQL server从入门精通----3种分页

    --分页语句
    --max id分页
    select top 4 * from District where id>(select ISNULL(max(id),0) from (select top 2 id from District order by Id) a)
    
    --not id 分页
    select top 4 * from District where id not in(select top 2 id from District )
    
    --ROW_NUMBER分页
    select * from (select  ROW_NUMBER() over(order by id) as number,* from District) a where number<=6 and number>=3
    
    
    --row_number over 讲解
    --就是给查询到的数据从1编号
    --语法一
    select ROW_NUMBER() over(order by id desc),* from District  --以id降序查询在编号,当然去到desc默认是升序
    --语法二
    select ROW_NUMBER() over(partition by name order by id),* from District --以name列分组在以id升序查询编号
    
    --注意:over里面的分组与排序执行等级是要低于 “where,group by,order by”的执行。
     ---------也就是是说会先把外面的的执行晚,在执行里面的,这样就会覆盖外面的 group by,order by;
    
    
    --最好是用id max方法 效率最高
    --当然也可以用存储过程进行分页,但相比之下效率是最低的
  • 相关阅读:
    System.Web.Http.Cors配置跨域访问的两种方式
    asp.net反向代理
    web.config SetAttributes
    remove name="ProxyModule“会导致重复执行
    去空格
    api签名
    C# HttpWebRequest获取COOKIES
    Request.Form接收不到post数据.
    webapi文档工具
    https://gogs.io/
  • 原文地址:https://www.cnblogs.com/CodeTaotao/p/4811976.html
Copyright © 2011-2022 走看看