SQL to return Effective Start Date based on Organization ID. If the Dept did not change since the new hire then the Eff Date should be the first effective start date rather than the current Eff Start Date based on any other changes
Below are the sample scenarios w/ expected output….

I already have an SQL for this, however it has 2 issues that I am still working on.
- Single Row Subquery error (where Sysdate equals to the Effective Start Date wherein there are 2 changes in the Org_ID on the same date, assuming I run this on March 31 2024)

- Wrong eff_start_date is being pulled if it follows a date with the same scenario above.
Expected output is 12-10-2023
Being pulled in the report is 10-29-2023

Maybe you can help me re-construct my SQL below to satisfy this conditions and be able to pull the correct date. Thanks