I have a list of duplicate rows in the DB with unique GUID types for IDs. Somethig like this:
ID Date Name
C3A19F77-0A99-4CA6-9375-A5062051BB86 2017-09-01 04:57:34.000 John
5252C4B7-FA62-4BDE-90F8-A5064051D801 2017-09-01 04:57:34.000 John
73EB45AE-8E69-468E-A6E5-A50670E55C0E 2019-09-01 13:50:53.000 Steve
5D0A3F64-6D55-4EFC-8961-A50620E4369B 2019-09-01 13:50:53.000 Steve
E2533E75-6E97-4966-A3B8-A50841055236 2016-09-03 15:51:26.000 Jill
134FC9F4-B86F-4864-943D-A50821064F83 2016-09-03 15:51:26.000 Jill
I'm trying to get rid of duplicates and grab one instance of GUID/ID for each unique row. Turn this into something like this:
ID Date Name
C3A19F77-0A99-4CA6-9375-A5062051BB86 2017-09-01 04:57:34.000 John
73EB45AE-8E69-468E-A6E5-A50670E55C0E 2019-09-01 13:50:53.000 Steve
E2533E75-6E97-4966-A3B8-A50841055236 2016-09-03 15:51:26.000 Jill
I found a pretty funky way to get distinct IDs by returning MAX(ID) on a row partitioned by date. It works but is using MAX() function on a GUID type to work as FIRST() normal?
SELECT Id, MAX(ID) OVER ( partition by sentDate) as DistinctId
Are there any unexpected issues I need to be aware of with this approach?