首页 > 数据库技术 > 详细

oracle row/column

时间:2021-05-07 10:41:39      阅读:12      评论:0      收藏:0      [点我收藏+]

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

技术分享图片

 

oracle row/column

原文:https://www.cnblogs.com/tingxin/p/14737438.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!