Skip to content
Advertisement

Group by name and return row with most recent date

Suppose you have the following data:

What would be the best way to group by name and return the row with the most recent date in Snowflake (ANSI SQL)? Expected output:

Advertisement

Answer

With QUALIFY you can keep the newest per name

As you will see in the doc’s it’s the same as Tim’s answer without the need for the nested select.

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