Posts

Showing posts from September, 2024

Snowflake Vs MS-SQL - Part 42 - Search Data

Image
           Search Data A table contains multiple columns and if you want to search a particular word in any one of these columns. Suppose you have data as below: + ---------------------------+-----------------+ | PLAY                      | CHARACTER       | | ---------------------------+-----------------| | All Well That Ends Well   | KING            | | Henry IV Part 1           | KING CLAUDIUS   | | John John                 | CHATILLON       | | King John                 | KING JOHN       | | Lear Lear                 | GLOUCESTER      | + ---------------------------+-----------------+ Expected Output + ---------------------------+----...

Snowflake Vs MS-SQL - Part 41 - NVL2

Image
          NVL2 A table contains 3 columns, if the value in the first column is NOT NULL then you have to return/display the value from the second column and if the value in the first column is NULL then you have to return/display the value from the third column. Suppose you have data as below: --------+--------+--------+ Col1    | Col2   | Col3   | --------+--------+--------+  0      | 5      | 3      |  0      | 5      | [ NULL ] |  0      | [ NULL ] | 3      |  0      | [ NULL ] | [ NULL ] |  [ NULL ] | 5      | 3      |  [ NULL ] | 5      | [ NULL ] |  [ NULL ] | [ NULL ] | 3      |  [ NULL ] | [ NULL ] | [ NULL ] | --------+--------+--------+ Expected Output --------+--------+--------+---------------+ Col1   ...

Snowflake Vs MS-SQL - Part 40 - Stored Procedure Call

Image
         Stored Procedure Call If you want to retrieve the data by calling a Stored Procedure. Suppose you are selecting a table inside a Stored Procedure and want to get the result using Stored Procedure. MS-SQL Server   You can achieve this by using the following approach.  In  Snowflake,  we can use a different approach . For more details, you can refer to the following  StoredProcedure . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 39 - EQUAL_NULL

Image
        EQUAL_NULL Your data is as below, if you make self join then it should return 3 records instead of 2 records by considering NULL.  Expected Output: MS-SQL Server   You can achieve this by using the  ISNULL  function.  In  Snowflake  we can use the similar function  IFNULL. However, Snowflake has another two approaches  which give you the same result. Function  EQUAL_NULL   Operator  IS [ NOT ] DISTINCT FROM   EQUAL_NULL is a function, while IS [ NOT ] DISTINCT FROM is an operator. EQUAL_NULL is used as a function call, while IS [ NOT ] DISTINCT FROM is used as part of a SQL expression. EQUAL_NULL: A function to compare two values, treating NULL as equal. IS [ NOT ] DISTINCT FROM: An operator to compare two values, treating NULL as equal or distinct based on the context. For more details, you can refer to the following  EQUAL_JOIN   or  IFNULL   or  IS_DISTINCT_FROM ...

Snowflake Vs MS-SQL - Part 38 - IFNULL

Image
        IFNULL/NVL Your data may often contain a NULL value and you need to display or replace it with some other value. As below, for NULL we are replacing it by Default . MS-SQL Server   You can achieve this by using the  ISNULL  function.  In  Snowflake  we can use the similar function IFNULL. However, Snowflake has another function  NVL  which gives you the same result. For more details, you can refer to the following  NVL   or  IFNULL . Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 37 - GROUP_BY_ALL

Image
       GROUP BY ALL Suppose you have the data as below: If you want to group on this dataset as below: MS-SQL Server   You can achieve this by using the  Group By clause.  In  Snowflake  we can use the same Group By clause; however, we can skip the list of tables. This will be helpful if you have fewer columns in Group By clause. For more details, you can refer to the following  Group_By_All .  Yogesh Shinde LinkedInProfile <<< Back   Next >>>