zoukankan      html  css  js  c++  java
  • 读取指定的记录数

    我要第一条,第二条,第三条,

     /*第一种 升序*/

    select top 1 * from table_A  where  (select count(1) from table_A where ID<= T.ID)  > 2


    select top 1  rn= (select count(1) from table_A where ID<= T.ID), * from table_A  where  (select count(1) from table_A where ID<= T.ID)  > 2

     /*第二种 升序*/

    select row_number()  over( order by  ID)  as  row_number, *   from  table_A

    select top 1 t.ID,t.Name from (select t.ID,t.Name,row_number() over(order by ID) rn from table_A ) as t where rn >2(第三条) 

    /*第三种 ID顺序asc 升序*/

    select top 1 * from table_A where ID not in (select top 1 ID from table_A)

     /*第四种   ID倒叙 desc 降序*/

     select * from table_A where id =(select  min(t.id) as id from
    (select top 3 id from  table_A order by id desc) as t)

  • 相关阅读:
    Linux file命令详解
    Linux stat命令详解
    Linux cut命令详解
    Linux tr命令详解
    Linux grep/egrep命令详解
    Linux awk命令详解
    Linux xargs命令详解
    MVC设计模式
    qt博客
    android
  • 原文地址:https://www.cnblogs.com/ruonanxiao/p/1779022.html
Copyright © 2011-2022 走看看