Skip to content
Advertisement

Select second most recent date from inner join

I have this query :

I get this result :

enter image description here

How can I select only the second most recent created_at date from each unique display_name ?

Advertisement

Answer

You could use row_number to assign a sequence to your dates and apply this before joining, then include as part of your join criteria, such as:

You could also apply this using a lateral join which would simplify further.

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