Snowflake Vs MS-SQL - Part 120 - Aggregate functions - MIN_BY and MAX_BY


Aggregate functions - MIN_BY and MAX_BY

Suppose you want to find the row containing the minimum value for a column and return the value of another column in that row.

Available Data:



Expected Output:


MS-SQL Server

You can achieve this by using built-in WINDOWS functions as below:



In Snowflake, we can use a similar approach as above; however, we can use MIN_BY as follows:




For more details, refer to the MIN_BY section.


Yogesh Shinde

Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Series

Snowflake Key Concepts

Snowflake Vs MS-SQL - Part 46 - RATIO_TO_REPORT