'SQL query to get address city change on a date

I have a query to find out the address details of an employee

Person_number           country     town/city   start_Date          end_date
--------------------------------------------------------------------------------
10                      CA          Toronto     01-feb-2022         10-feb-2022
10                      CA          Ottawa      11-feb-2022         31-dec-4712

11                      CA          Toronto     10-feb-2022         31-dec-4712

12                      AB          Greenvilee  15-feb-2022         20-feb-2022
12                      AB          Portvilee   21-feb-2022         31-dec-4712

13                      CA          North york  01-feb-2022         09-feb-2022
13                      CA          Waterloo    10-feb-2022         31-dec-4712

I want I want to create a query to get the data only for those employees whose town/city value has changed within the parameter date.

For example: if I pass the parameter date as 01-feb-17-feb 2022, I should get the following output:

Person_number           country     current_town    previous_town   effective_date_ofchange
10                       CA          Toronto            Ottawa          11-feb-2022 
13                       CA          North york         Waterloo        10-feb-2022

person #11 will not come as there is no change within the date. Person#12 will not come as the change is after the parameter date.

Can this be achieved with any analytical function ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source