I have to find historical data for a report until the effective date. There is a date tracked table that has the following data -
person_number start_date end_date name position
10 01/01/2016 31/12/4712 Scott Manager
11 02/01/2006 25/06/2017 Kirk Associate
11 26/06/2017 18/03/2023 Kirk Snr. Associate
11 19/03/2023 31/12/4712 Kirk DIRECTOR
When I pass the effective date as today's date in the query -
query 1
**select person_number, name, position from abc
where nvl(:p_eff_date,trunc(sysdate)) between start_Date and end_date**
person_number start_date end_date name position
10 01/01/2016 31/12/4712 Scott Manager
11 19/03/2023 31/12/4712 Kirk DIRECTOR
I want to display the historial output now. i.e. till the effective date that we pass in the parameter. If we pass 01st march 2023 date, the output should be
person_number start_date end_date name position
10 01/01/2016 31/12/4712 Scott Manager
11 02/01/2006 25/06/2017 Kirk Associate
11 26/06/2017 18/03/2023 Kirk Snr. Associate
The last row will still come because 01st march data is in this time frame. How to tweak the #query 1 to give this result