unit_id is unique, I want to select latest unit_id by date for a particular ref_id and generate flag for unit_address change as Yes or No, if date is same select top record.
Group by ref_id and select top two max/latest dates and determine if there is change in unit_address if yes then show Yes else No