I want to know if there is an easier way to grab the most recent record per unique ID than what I'm doing.
right now I use a CTE -- add a RN partitioned by the date, with a follow up select statement that filters for RN = 1.
I have a fellow analyst who uses group by unique ID having date = max(date), but that never seems to work for me and I can't figure out why ---the error tells me to group all the other columns. Once I group all the columns, it produces the same result (all records for each unique ID).
Hoping someone comes in clutch with a solution!
I like the CTE method, but here's one alternative:
Create table and insert data:
Query for obtaining all columns per user based on max date:
Output: