MSSQL: select only row with max value

Another approach for http://blog.interakt.hr/?p=610

select
	id, case_id, file_path, date_created
  from (
        select id, case_id, file_path, date_created, row_number() over (partition by case_id order by date_created desc) as rn
         from TMP_reminders
        ) as dtbl_unique_reminders
  where dtbl_unique_reminders.rn = 1

SOURCE: https://stackoverflow.com/questions/38912808/select-only-row-with-maxid-in-sql-server


Comments are closed.