Assuming that when you say “most recent,” you mean “closest,” since “the stored date is the least number of days from the current date, and we don’t care whether it is before or after the current date,” then should do this (trivial debugging may be required):
SELECT ID, Name, AppointmentDate
from (select
ID
,Name
,AppointmentDate
,row_number() over (partition by ID order by abs(datediff(dd, AppointmentDate, getdate()))) Ranking
from MyTable) xx
where Ranking = 1
row_number() SQL 2005 . "" , .
, :
.