48 lines
1.4 KiB
Markdown
48 lines
1.4 KiB
Markdown
#DB #Database
|
|
|
|
- 통계를 위한 Time Table 생성
|
|
```sql
|
|
|
|
create table ucm.sacp_report_times as
|
|
select dt_se, hh, mi, ss
|
|
from (
|
|
select 'S' as dt_se, hh, mi, ss
|
|
from (SELECT lpad((ROWNUM -1), 2, '0') AS hh FROM DUAL CONNECT BY LEVEL <= 24) h
|
|
, (SELECT lpad((ROWNUM -1), 2, '0') AS mi FROM DUAL CONNECT BY LEVEL <= 60) m
|
|
, (SELECT lpad((ROWNUM -1), 2, '0') AS ss FROM DUAL CONNECT BY LEVEL <= 60) s
|
|
union all
|
|
select 'M' as dt_se, hh, mi, null as ss
|
|
from (SELECT lpad((ROWNUM -1), 2, '0') AS hh FROM DUAL CONNECT BY LEVEL <= 24) h
|
|
, (SELECT lpad((ROWNUM -1), 2, '0') AS mi FROM DUAL CONNECT BY LEVEL <= 60) m
|
|
union all
|
|
select 'H' as dt_se, hh, null, null as ss
|
|
from (SELECT lpad((ROWNUM -1), 2, '0') AS hh FROM DUAL CONNECT BY LEVEL <= 24) h
|
|
) tm
|
|
order by dt_se, hh, mi,ss
|
|
|
|
|
|
```
|
|
|
|
- 집계 기준 일시 일괄 생성
|
|
```sql
|
|
|
|
CREATE TABLE UCM.SACP_STATS_TIMES (
|
|
DT VARCHAR(32) not null,
|
|
YMD VARCHAR(8),
|
|
HH VARCHAR(8),
|
|
MI VARCHAR(8),
|
|
SS VARCHAR(8),
|
|
CONSTRAINT PK_SACP_STATS_TIMES PRIMARY KEY (DT)
|
|
);
|
|
|
|
-- 월별 생성(년월일시분초-yyyyMNddhh24miss)
|
|
insert into ucm.sacp_stats_times
|
|
select ymd||hh||mi||ss as dt, ymd, hh, mi, ss
|
|
from (SELECT TO_CHAR(TO_DATE('202409'||'01','YYYYMMDD') -1 + LEVEL, 'YYYYMMDD') AS ymd FROM DUAL CONNECT BY LEVEL <= 31 ) d
|
|
, (select * from ucm.sacp_report_times where dt_se = 'S')
|
|
|
|
|
|
```
|
|
|
|
|