[Oracle]NUMTODSINTERVAL()
오라클 NUMTODSINTERVAL()
NUMTODSINTERVAL()
-
NUMTODSINTERVAL(n, interval_unit)
의 형태
NUMTODSINTERVAL converts n to an INTERVAL DAY TO SECOND literal. The argument n can be any NUMBER value or an expression that can be implicitly converts to a NUMBER value. The argument interval_unit can be of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. The value for interval_unit specified the unit of n and must resolve to one of the following string values :
- 'DAY'
- 'HOUR'
- MINUTE'
- 'SECOND'
interval_unit is case insensitive. Leading and trailing values within the parentheses are ignored. By default, the precision of the return is 9.
SQL>SELECT NUMTODSINTERVAL(100, 'day') FROM DUAL ;
--> +100 00:00:00.000000
오라클 OE 계정으로 테스트 가능.
SQL>
SELECT
manager_id,
last_name,
hire_date,
COUNT(*) OVER (PARTITION BY manager_id ORDER BY hire_date RANGE NUMTODSINTERVAL(100, 'day') PRECEDING) AS t_count
FROM employees
ORDER BY last_name, hire_date ;