Obsidian/Recognition/Programing/Tibero/DB 통계 관련.md

24 lines
835 B
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
```