Data/Oracle(8)
-
Oracle 생성날짜를 통해서 나이(age)를 표시하기
WITH date_diff AS ( SELECT TO_DATE('20250101 132344', 'YYYYMMDD HH24MISS') AS created_date, SYSDATE AS current_date FROM dual)SELECT CASE WHEN current_date - created_date >= 1 THEN TRUNC(current_date - created_date) || ' days' WHEN (current_date - created_date) * 24 >= 1 THEN TRUNC((current_date - created_date) * 24) || ' hours' ..
2025.01.18 -
Oracle SYSDATE와 SYSTIMESTAMP의 차이
nanoseconds가 필요하면 SYSTIMESTAMP를 사용해야 함
2025.01.18 -
Oracle 날짜 형변환 하기
'2025-01-16T07:14:47Z'를 날짜로 변환하기SELECT TO_DATE('2025-01-16T07:14:47Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"') FROM DUAL;SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') FROM DUAL;
2025.01.18 -
Oracle 소수 첫째 자리에서 반올림
SELECT ROUND(10000000/1234, 1) AS resultFROM DUAL;
2025.01.15 -
Oracle NVL 대신 COALESCE 사용하기
2개의 인수SELECT NVL(column1, 'default') AS resultFROM table_name;3개 이상 인수SELECT COALESCE(column1, column2, 'default') AS resultFROM table_name;
2025.01.12 -
Oracle 5분 단위로 시간을 집계하여 최대값 구하기
5분 단위로 데이터 분류SELECT TRUNC(DATE_COLUMN, 'MI') + (5 - MOD(TO_NUMBER(TO_CHAR(DATE_COLUMN, 'MI')), 5)) / (24 * 60) AS rounded_up_dateFROM YOUR_TABLE;5분 단위로 최대값 구하기SELECT TRUNC(DATE_COLUMN, 'MI') + (5 - MOD(TO_NUMBER(TO_CHAR(DATE_COLUMN, 'MI')), 5)) / (24 * 60) AS rounded_up_date, MAX(VALUE_COLUMN) AS max_valueFROM YOUR_TABLEGROUP BY TRUNC(DATE_COLUMN, 'MI') + (5 - MOD(TO_NUMBE..
2024.11.24