If I have a table like this
fid name date
---------------------
1 John1 2020-10-08
1 John2 2020-10-08
1 John3 2018-06-04
2 Tom1 2019-10-08
I want to preserve the row for each fid
that has the most recent date. However, if there are multiple, keep only 1 (any of them is fine). So the final result should end up like
fid name date
---------------------
1 John1 2020-10-08
2 Tom1 2019-10-08
Does anyone know how to do this in SQL Server? I use v14 (2017) if that matters.
Problem is if I group by fid
and do Max(date)
, I get 1 record per fid
, but then when I left join on it to get the other columns it gives me back 2 records since the most recent date shows up twice.