Believe me, I tried to find luck for this problem. I had MYSQL and SQLServer solutions, not Oracle, and not the specific convolution I need. Since Cross Apply is not available in the version of Oracle I'm using, I hit the road block.
The problem is simple for many of you.
The beginning of the universe for me is 13 months.
I have a table with
CREATE TABLE TBLTESTAUM (
ORDER_NO NUMBER(10,0) NOT NULL ENABLE,
RECORD_DATE DATE,
Order_SEQUENCE NUMBER(5,0) NOT NULL ENABLE,
CLASS NUMBER(3,0));
INSERT INTO TBLTESTAUM VALUES (1234, '29-Aug-2015', 34, 459);
INSERT INTO TBLTESTAUM VALUES (1234, '20-Jun-2016', 35, 877);
INSERT INTO TBLTESTAUM VALUES (1234, '20-Jun-2016', 37, 877);
INSERT INTO TBLTESTAUM VALUES (1234, '02-Jul-2016', 39, 122);
INSERT INTO TBLTESTAUM VALUES (1234, '28-Jul-2016', 40, 122);
INSERT INTO TBLTESTAUM VALUES (1234, '31-Jul-2016', 41, 311);
INSERT INTO TBLTESTAUM VALUES (1234, '10-Aug-2016', 42, 311);
INSERT INTO TBLTESTAUM VALUES (1234, '18-Aug-2016', 44, 110);
INSERT INTO TBLTESTAUM VALUES (1234, '20-Aug-2016', 45, 110);
Note:
- 20 / Jul / 2015 in the first box.
- The Seq field may or may not have each value. Perhaps some of them are missing. If you want to use it.
- Not Nullable for Sequence is ignored.
So, 13 months give me 07/22/2015, today.
, "CLASS", , CLASS. , , . CLASS.
-
Order Num WeekDate CLASS
123 27-Jul-15 459
123 3-Aug-15 459
123 10-Aug-15 459
123 17-Aug-15 459
123 24-Aug-15 459
123 31-Aug-15 459
123 7-Sep-15 459
Dates and Order Num to continue till next match in TBLTESTAUM is found
123 20-Jun-16 877
123 27-Jun-16 122
123 4-Jul-16 122
123 11-Jul-16 122
123 25-Jul-16 311
123 1-Aug-16 311
123 8-Aug-16 311
123 15-Aug-16 110
123 22-Aug-16 110
. , .
.
. , , .
.
PS: 10 . . , .