일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- 오라클
- switch
- 호환성
- php
- json
- MYSQL
- maven
- 문자열
- DB
- @RequestBody
- 웹 플랫폼 설치 관리자
- 날짜
- jquery
- Oracle
- RADIO
- spring form tag
- SSL
- null
- 톰캣
- 네이버스마트 에디터
- 전자정부 표준프레임워크
- 이클립스
- JSTL
- checbox
- html
- HTML5
- 스크립트
- exception
- java
- 한글
- Today
- Total
개인적인 정리
Oracle LISTAGG() 본문
오라클 LISTAGG()
LISTAGG()
-
LISTAGG(measure_expr, 'delimiter') WITHIN GROUP(order_by_clause),
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.
- As a single-set aggregate function, LISTAGG operates on all rows and returns a single output row.
- As a group-set aggregate, the function operates on and returns an output row for each group defined by the GROUP BY clause.
- As an analytic function, LISTAGG partitions the query result set into groups based on one or more expression in the query_partition_clause.
The arguments to the function are subject to the following rules:
- The measure_expr can be any expression. Null values in the measure column are ignored.
- The delimiter_expr designates the string that is to separate the measure values.
This clause is optional and defaults to NULL. - The order_by_clause determines the order in which the concatenated values are returned. The function is deterministic only if the ORDER BY column list archieved unique ordering.
The return data type is RAW if the measure column is RAW; otherwise the return value is VARCHAR2.
오라클 oe계정 또는 hr 계정으로 테스트가 가능하다.
Aggregate Example
SQL>
SELECT
LISTAGG(last_name, ';') WITHIN GROUP(ORDER BY hire_date, last_name) "Emp_list",
MIN(hire_date) "Earliest"
FROM employees
WHERE department_id =30 ;
--> Raphaely;Khoo;Tobias;Baida;Himuro;Colmenares 2002/12/07
SQL>
SELECT
department_id "Dept",
LISTAGG(last_name, ';') WITHIN GROUP(ORDER BY hire_date) "Employees"
FROM employees
GROUP BY department_id
ORDER BY department_id;
Analytic Example
SQL>
SELECT
department_id "Dept",
hire_date "Date",
last_name "Name",
LISTAGG(last_name, ';') WITHIN GROUP (ORDER BY hire_date, last_name) OVER (PARTITION BY department_id) as "Emp_list"
FROM employees
WHERE hire_date < '01-SEP-2003'
ORDER BY "Dept", "Date", "Name";
'DB > ORACLE' 카테고리의 다른 글
[Oracle] LOG() (0) | 2020.04.08 |
---|---|
Oracle LOCALTIMESTAMP() (0) | 2020.04.08 |
Oracle LNNVL() (0) | 2020.04.08 |
Oracle LN() (0) | 2020.04.08 |
Oracle LENGTH() (0) | 2020.04.07 |
Oracle LEAD() (0) | 2020.04.07 |
Oracle LAST_VALUE() (0) | 2020.04.06 |
ORACLE LAST_DAY() (0) | 2020.04.06 |