2018년 2월 4일 일요일
SYS_CONNECT_BY_PATH
Row의 데이타를 한 컬럼으로 표현해야되는 경우 아래 함수 적용.
Purpose
SYS_CONNECT_BY_PATH is valid only in hierarchical queries. It returns the path of a column value from root to node, with column values separated by char for each row returned by CONNECT BY condition.
Both column and char can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of VARCHAR2 datatype and is in the same character set as column.
Examples
The following example returns the path of employee names from employee Kochhar to all employees of Kochhar (and their employees):
SELECT LPAD(' ', 2*level-1)||SYS_CONNECT_BY_PATH(last_name, '/') "Path"
FROM employees
START WITH last_name = 'Kochhar'
CONNECT BY PRIOR employee_id = manager_id;
Path
---------------------------------------------------------------
/Kochhar
/Kochhar/Greenberg
/Kochhar/Greenberg/Faviet
/Kochhar/Greenberg/Chen
/Kochhar/Greenberg/Sciarra
/Kochhar/Greenberg/Urman
/Kochhar/Greenberg/Popp
/Kochhar/Whalen
/Kochhar/Mavris
/Kochhar/Baer
/Kochhar/Higgins
/Kochhar/Higgins/Gietz
피드 구독하기:
댓글 (Atom)
Creating CRC32 Hex string
public String getCRC32HexaString(String paramString) throws Exception { byte bytes[] = paramString.getBytes(DEFAULT_CHARSET); Che...
-
간혹 날짜 더미 Inline view가 필요한 경우 다음 SQL로 처리 SELECT TO_CHAR(CURRENT_DATE -7 + LEVEL,'YYYY-MM-DD') FROM DUAL CONNECT BY LEVEL
-
Mysql에서는 재귀호출함수가 없어서 날짜 더미테이블 생성할때는 이게 제일 간단한듯.. select dt.yyyymmdd from ( select curdate() - INTERVAL (a.a + (10 * b.a...
댓글 없음:
댓글 쓰기