zoukankan      html  css  js  c++  java
  • oracle row/column

    LISTLAG

    LISTAGG function Syntax
    Aggregate Syntax: LISTAGG(measure_expr [, 'delimiter']) WITHIN GROUP (order_by_clause)
    Analytic Syntax : LISTAGG(measure_expr [, 'delimiter']) WITHIN GROUP (order_by_clause)[OVER query_partition_clause]
    For a specified measure, LISTAGG orders data within each group specified
    in the ORDER BY clause and then concatenates the values of the measure column.

    SELECT DEPARTMENT_ID, LISTAGG(FIRST_NAME, '|')
             WITHIN GROUP (ORDER BY  FIRST_NAME) "Emp_list" 
    FROM EMPLOYEES
    group by DEPARTMENT_ID

     PIVOT

    select * from 
    (
    select   department_id, job_id
    from
    employees
    )
    pivot
    (
    count(1) for job_id in  ('MK_MAN','MK_REP','PU_CLERK','PU_MAN')
    )
    ORDER BY 1

    select * from 
    (
    select   department_id,job_id, salary
    from
    employees
    )
    pivot
    (
    SUM(salary) for job_id in  ('MK_MAN','MK_REP','PU_CLERK','PU_MAN')
    )
    ORDER BY 1

    每天进步一点点,多思考,多总结 版权声明:本文为CNblog博主「zaituzhong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
  • 相关阅读:
    十四
    十三
    十二
    十一
    用Linq从一个集合选取几列得到一个新的集合-可改列名
    LINQ入门(完结篇)
    LINQ入门(下篇)
    LINQ入门(中篇)
    LINQ入门(上篇)
    MVC中View往Controllers传数据的方式-已发
  • 原文地址:https://www.cnblogs.com/tingxin/p/14737438.html
Copyright © 2011-2022 走看看