サブシステムに接続するプロセスがあり、このタイムスタンプで追跡しています。私が知りたいのは、N 分の時間間隔で接続されたプロセスの最大数です。
この時間間隔はプロセスの TIMEOUT 間隔であるため、接続時に経過時間のカウントダウンが開始されます。したがって、間隔は「フローティング」間隔です。
簡単にするために、この間隔の長さは 5 分で、接続時間はミリ秒ではなく分単位です。
この数値を計算するための PL/SQL 関数は既にありますが、SQL のみを使用して計算できるかどうかを知りたいです。
例:
09:10 09:15 09:20 09:25 09:30
| | | | |
----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---
| | | | |
| | | | | | | | | | |
a b c a c a b c d a f <-- PROCESSES
f b <-- PROCESSES
PROCESSES テーブルの SQL は次のとおりです。
create table PRCS
(
prc_id NUMBER(12) not null,
prc_name VARCHAR2(25) not null
);
alter table PRCS add constraint PRCS_PK primary key (PRC_ID);
alter table PRCS add constraint PRCS_UK unique (PRC_NAME);
insert into PRCS values('1', 'a');
insert into PRCS values('2', 'b');
insert into PRCS values('3', 'c');
insert into PRCS values('4', 'd');
insert into PRCS values('5', 'e');
insert into PRCS values('6', 'f');
CONNECTIONS テーブルの SQL は次のとおりです。
create table CON_JOURNAL
(
con_id NUMBER(12) not null,
con_date TIMESTAMP(6) not null,
con_prc NUMBER(12) not null
)
;
alter table CON_JOURNAL add constraint CON_PK primary key (CON_ID);
alter table CON_JOURNAL add constraint CON_UK unique (CON_DATE, CON_PRC);
alter table CON_JOURNAL add constraint CON_PRC_FK foreign key (CON_PRC)
references PRCS (PRC_ID);
insert into CON_JOURNAL values( '1', to_date('2013.01.09 09:12', 'yyyy.mm.dd hh24:mi'), '1');
insert into CON_JOURNAL values( '2', to_date('2013.01.09 09:13', 'yyyy.mm.dd hh24:mi'), '2');
insert into CON_JOURNAL values( '3', to_date('2013.01.09 09:14', 'yyyy.mm.dd hh24:mi'), '3');
insert into CON_JOURNAL values( '4', to_date('2013.01.09 09:18', 'yyyy.mm.dd hh24:mi'), '1');
insert into CON_JOURNAL values( '5', to_date('2013.01.09 09:19', 'yyyy.mm.dd hh24:mi'), '3');
insert into CON_JOURNAL values( '6', to_date('2013.01.09 09:21', 'yyyy.mm.dd hh24:mi'), '1');
insert into CON_JOURNAL values( '7', to_date('2013.01.09 09:22', 'yyyy.mm.dd hh24:mi'), '2');
insert into CON_JOURNAL values( '8', to_date('2013.01.09 09:23', 'yyyy.mm.dd hh24:mi'), '3');
insert into CON_JOURNAL values( '9', to_date('2013.01.09 09:24', 'yyyy.mm.dd hh24:mi'), '4');
insert into CON_JOURNAL values('10', to_date('2013.01.09 09:24', 'yyyy.mm.dd hh24:mi'), '6');
insert into CON_JOURNAL values('11', to_date('2013.01.09 09:26', 'yyyy.mm.dd hh24:mi'), '1');
insert into CON_JOURNAL values('12', to_date('2013.01.09 09:26', 'yyyy.mm.dd hh24:mi'), '2');
insert into CON_JOURNAL values('13', to_date('2013.01.09 09:29', 'yyyy.mm.dd hh24:mi'), '6');
ご協力ありがとうございました、
SK