여러행을 하나의 컬럼으로 합치기

 

--Oracle version : 11g
SELECT LISTAGG(CODE, ',') WITHIN GROUP(ORDER BY CODE DESC) AS PLUS_COLUMN 
  FROM COM_CODE
WHERE ROWNUM < 5;

 

--Oracle version : 10g
SELECT WM_CONCAT(CODE) AS PLUS_COLUMN
  FROM COM_CODE
WHERE ROWNUM < 5;

 

--Oracle version : 9i
SELECT SUBSTR(XMLAGG(XMLELEMENT(X, ',', CODE) ORDER BY CODE).EXTRACT('//text()'), 2) AS PLUS_COLUMN
  FROM COM_CODE
WHERE ROWNUM < 5;

 

반응형

--캐릭터셋 조회
SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET';

 

--CONVERT( '대상 문자열', '타겟 인코딩', '소스 인코딩')
SELECT COMMENTS
          , CONVERT(COMMENTS, 'AL32UTF8', 'KO16KSC5601') AS COMMENTS_CONVERT
    FROM ALL_COL_COMMENTS WHERE TABLE_NAME = 'COM_CODE';

반응형

--1시간전
SELECT * FROM TABLE_NAME AS OF TIMESTAMP((SYSDATE-1/24));

 

--특정시간
SELECT * FROM TABLE_NAME AS OF TIMESTAMP(TO_DATE('20181101140000', 'YYYYMMDDHH24MISS'));

반응형

+ Recent posts