Snowflake Vs MS-SQL - Part 6 - MAX among columns

    



MAX among columns 

Suppose if you want to get the maximum value among multiple columns.  In this case, among columns Column_Date1 & Column_Date2, we want the maximum to be selected.


 

MS-SQL Server 

You can NOT achieve this directly but using little bit tricky way.




However in Snowflake we can achieve this by using Conditional Expression Functions like GREATEST.




Note: If one of the columns contains NULL then it returns the NULL value. To overcome this, you can use variation of this GREATEST_IGNORE_NULLS.


For more details, you can refer the following LINK.


On similar line, you use LEAST for minimum value among multiple columns.

Yogesh Shinde

LinkedInProfile

<<< Back Next >>>


Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP