Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sql Query for to compare row vice dates

MBAppsMay 5 2023

Hi Team,

Could please provide us the sql query logic to achieve below scenario.

Requirement : we need to compare 2nd row with 1 st row (between start date & end date) , If the 2nd row start date or end date is appearing in between we need to through exception.

like same

We need to compare 3rd row same like as above with 2nd row and 1st row.

4th row with 3rd,2nd,1st…

The Row count is dynamic it may be 1,2,3,4….

<table><tbody><tr><td style="height:14.5pt;width:48pt;">&nbsp;</td><td style="border-left-style:none;width:48pt;">start date</td><td style="border-left-style:none;width:48pt;">end date</td><td style="border-left-style:none;width:48pt;">&nbsp;</td></tr><tr><td style="border-top-style:none;height:14.5pt;text-align:right;">1</td><td style="border-left-style:none;border-top-style:none;text-align:right;">Jan2021</td><td style="border-left-style:none;border-top-style:none;text-align:right;">Dec2021</td><td style="border-left-style:none;border-top-style:none;">&nbsp;</td></tr><tr><td style="border-top-style:none;height:14.5pt;text-align:right;">2</td><td style="border-left-style:none;border-top-style:none;text-align:right;">Mar2021</td><td style="border-left-style:none;border-top-style:none;text-align:right;">Aug2021</td><td style="border-left-style:none;border-top-style:none;">&nbsp;</td></tr><tr><td style="border-top-style:none;height:14.5pt;text-align:right;">3</td><td style="border-left-style:none;border-top-style:none;text-align:right;">June2021</td><td style="border-left-style:none;border-top-style:none;text-align:right;">Nov2021</td><td style="border-left-style:none;border-top-style:none;">&nbsp;</td></tr></tbody></table>
Comments
Post Details
Added on May 5 2023
3 comments
138 views