zoukankan      html  css  js  c++  java
  • Oralce分析函数

    1 列传行  listagg(city,',')  within GROUP (order by city)    over (partition by nation) rank 

     with temp as(  
          select 500 population, 'China' nation ,'Guangzhou' city from dual union all  
          select 1500 population, 'China' nation ,'Shanghai' city from dual union all  
          select 500 population, 'China' nation ,'Beijing' city from dual union all  
          select 1000 population, 'USA' nation ,'New York' city from dual union all  
          select 500 population, 'USA' nation ,'Bostom' city from dual union all  
          select 500 population, 'Japan' nation ,'Tokyo' city from dual   
        )  
        select population,  
               nation,  
               city,  
               listagg(city,',') within GROUP (order by city) over (partition by nation) rank  
        from temp 

    参考帖子 :http://dacoolbaby.iteye.com/blog/1698957

    2 分割函数

    select name ,workcode,
    NVL(SUBSTR(LTRIM(contract1, '-'),
                      0,
                      INSTR(LTRIM(contract1, '-'), '-', 1) - 1),
               LTRIM(contract1, '-')) AS contract1_name,
               REGEXP_SUBSTR(LTRIM(contract1, '-'), '[^-]+', 1, 2) AS contract1_begin,
               REGEXP_SUBSTR(LTRIM(contract1, '-'), '[^-]+', 2, 3) AS contract1_end,
               REGEXP_SUBSTR(LTRIM(contract1, '-'), '[^-]+',3,4) AS contract1_type

    from  lsq_result2018_1

    lsq_result2018_1 的表结构

     

    分割后:

  • 相关阅读:
    帮同事整理的 C# 调用 C++ 回调函数
    解决VS2010下使用NUnit 无法进行调试的问题
    Linux /var/log/messages 偶尔会发生time reset +6.288863s
    linux设置静态路由
    os auto installtion
    read 在bash ksh下的不同表现
    C#编码规范1
    C#中new一个对象时,发生了什么事?
    C# 实例化类的执行顺序
    C#类注释规范
  • 原文地址:https://www.cnblogs.com/abc8023/p/8483131.html
Copyright © 2011-2022 走看看