Имея эту настройку:
CREATE SEQUENCE "SEQ_TABLE_3" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 2206 NOCACHE ORDER NOCYCLE NOKEEP NOSCALE GLOBAL ;
CREATE TABLE TABLE_3 (
ID NUMBER DEFAULT SEQ_TABLE_3.nextval NOT NULL
,DATE_INI DATE NOT NULL
,DATE_FIN DATE NOT NULL
,ELEMENTS NUMBER
);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),3);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),2);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),1);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),5);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),4);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),6);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),9);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),1);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),2);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),4);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),5);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),6);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),2);
Insert into TABLE_3 (DATE_INI,DATE_FIN,ELEMENTS) values (to_date('19/04/01','RR/MM/DD'),to_date('19/04/10','RR/MM/DD'),7);
commit;
Я пытаюсь получить этот результат:
Идея заключается в имея date_ini
и date_fin
, воссоздайте строки со значениями даты, которые будут между date_ini
и date_fin
и суммой всех elements
. Если честно, я не знаю с чего начать