I have below records in table
APP_No Stage Start_Date End_Date
A123 L1 01-01-19 02-01-19
A123 D1 01-03-19 05-03-19
A345 L1 01-01-19 02-01-19
A345 D1 01-03-19 05-03-19
I want to search records for stage D1 for the month of Mar19
but this should include data for L1 stage also, since related app ID fall between same Mar19 date range.
I have used condition in where clause as : trunc(Col_Name) BETWEEN trunc (sysdate, 'mm')/current month/ AND SYSDATE
Please help with solution
Best Answer
Try ans use
EXISTS
to get all records where another (or the same for that matter) exists with the same app ID, a stage of'D1'
and the start date or the end date in march.Assuming you're on Oralce, this could look like this: