I have a table called PRODUCTS
and each PRODUCT_NO_REGISTRATION_NO
is allowed to be used only once that is product start date and return date should not clashing.
We return the products and return date is entered in ACTUAL_RETURN_DATE
and if ACTUAL_RETURN_DATE
is null we take END_DATE
as return date.
You could see the records here
For example PRODUCT_NO_REGISTRATION_NO is clashing, as HP_2014 is returned on 18-Jun-2001, however HP_2012 same PRODUCT_NO_REGISTRATION_NO is allotted on 18-Jun-2001.
How can I find out using sql whether records are overlapping?
Update 1
There was a modification in table PRODUCTS
to include PRODUCT_EXTENSION_NO
.
Combination of PRODUCT_NO,PRODUCT_NO_REGISTRATION_NO and PRODUCT_EXTENSION_NO
becomes a unique row (composite primary key).
Rules are as below
Each PRODUCT_NO_REGISTRATION_NO
is allowed to be used only once that is product start date and return date should not clashing.
We return the products and return date is entered in ACTUAL_RETURN_DATE
and if ACTUAL_RETURN_DATE
is null we take END_DATE
as return date.
PRODUCT_NO
has extensions, so the END_DATE
is extended.
E.g. if you see the records
PRODUCT_NO
- ORP76
with PRODUCT_EXTENSION_NO
- 1
is clashing with PRODUCT_NO
- ORP100
with PRODUCT_EXTENSION_NO
- 0
.
How can I find out using sql whether records are overlapping, extension of PRODUCT_NO
is allowed though. i.e. PRODUCT_NO
ORP76
with extension 0
and extension 1 are basically extended.