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

oracle row/column

 

 

 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

oracle row/column

 

 

 

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

 

oracle row/column

上一篇:树莓派安装mysql


下一篇:mysql实现按照汉字拼音排序