zoukankan      html  css  js  c++  java
  • ORACLE Keep dense_rank

    The DENSE_RANK function works return sequence value for the order seqence.

    example:

    SQL> with t as (
      
    2  select 1 mon, 'Jon' name,24 age, 100000 money from dual union all
      
    3  select 1'Kim',243230000 from dual union all
      
    4  select 1'Jissca',25235556565 from dual
      
    5  )
      
    6  select mon,name,age,money,dense_rank() over (partition by mon order by money) rank from t;
     
           MON NAME          AGE      
    MONEY       RANK
    ---------- ------ ---------- ---------- ----------
             1 Jon            24     100000          1
             
    1 Kim            24    3230000          2
             
    1 Jissca         25  235556565          3
     
    SQL
    >

     The FIRST or LASTfunction can used to return the first or last value for order sequence,

    Say we want  to display the min value of money,age,along with the lowest and highest within their monwe may use something like:

    SQL> with t as (
      
    2  select 1 mon, 'Jon' name,24 age, 100000 money from dual union all
      
    3  select 1'Kim',243230000 from dual union all
      
    4  select 1'Jissca',25235556565 from dual
      
    5  )
      
    6  select mon,min(age) keep (dense_rank first order by money)  age, min(moneymoney
      
    7    from t
      
    8  group by mon;
     
           MON        AGE      
    MONEY
    ---------- ---------- ----------
             1         24     100000
     
    SQL
    >
  • 相关阅读:
    tensorflow搭建神经网络基本流程
    为什么Linux 实例执行 df 和 du 查看磁盘时结果不一致
    MySQL高可用架构之MHA
    Postgresql 用户管理
    PXE+Kickstart无人值守安装CentOS 7
    linux shell实用常用命令
    常用压缩命令
    mongodb 备份还原
    mongodb 备份脚本
    mongodb 日志清理
  • 原文地址:https://www.cnblogs.com/zeromyth/p/1603702.html
Copyright © 2011-2022 走看看