Skip to content
Advertisement

Get max dates for each customer

Let’s say I have a customer table like so:

I want to get 1 row per customer id that has the max(start_date) and if it’s the same date will use the max(created_at).

Result should look like this:

I’m having a hard time with window functions as I thought a partition by id would work but I have 2 dates. Maybe I use a group by?

Advertisement

Answer

please try this one, you could use order by two columns

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement