Posts

Snowflake Vs MS-SQL - Part 91 - ARRAY UNNEST - FLATTEN

Image
ARRAY UNNEST - FLATTEN If you have an array saved in a table and want to generate each value in each row as below: MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use  FLATTEN  as follows: For more details, refer to the  FLATTEN  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>> Snowflake Vs MS-SQL - Series

Snowflake Vs MS-SQL - Part 90 - Replace the String - INSERT - STUFF

Image
Replace the String - INSERT - STUFF If you want to delete a part of a string and then insert another string into the original string at a specified position. MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use INSERT  as follows: For more details, refer to the  INSERT  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>> Snowflake Vs MS-SQL - Series

Snowflake Vs MS-SQL - Part 89 - Form the DATE from Parts DATE_FROM_PARTS

Image
Form the DATE from Parts DATE_FROM_PARTS If you want to form the date from Parts like Day, Month & Year. MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use a similar approach as above; however, we can use  DATE_FROM_PARTS  as follows: For more details, refer to the  DATE_FROM_PARTS  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 88 - Count of non-NULL records of the column using ILIKE

Image
Count of non-NULL records of the column using ILIKE If you want to get the Count of non-NULL records of the column. MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use a similar approach as above; however, we can use  ILIKE  as follows: For more details, refer to the  ILIKE  section. Yogesh Shinde LinkedInProfile     <<< Back   Next >>>

Snowflake Vs MS-SQL - Series

Image
Snowflake Vs MS-SQL - Series Part 108 -  Filter Columns in Result Grid -  Part 108 Part 107 - Create or Alter Table - Add Column - Part 107 Part 106 - Table Structure - Describe - Part 106 Part 105 - PIVOT - Custom alias to column name - Part 105 Part 104 - Row Comparison - HASH - Part 104 Part 103 - ORDER BY ALL - SORTING - Part 103 Part 102 - Last Value in the Series - Part 102 Part 101 - Trigonometry Functions - Geometry - Part 101 Part 100 - Split String into Different Columns - Part 100 Part 99 - Multi-Table Insert based on condition - Part 99 Part 98 -  Create Table If Not Exists - Part 98 Part 97 - Identify Data Type - SYSTEM$TYPEOF - Part 97 Part 96 -  Row Last Updated - ROW_TIMESTAMP   -  Part 96 Part 95 -  Date and Time - INTERVAL   -  Part 95 Part 94 -  BOOLAND_AGG   -  Part 94 Part 93 -  MERGE ALL BY NAME   -  Part 93 Part 92 -  Stop or Cancel the Running Query   -  Part 92 Part 91...

Snowflake Vs MS-SQL - Part 87 - UTC Time - CONVERT TIMEZONE

Image
          UTC Time - CONVERT TIMEZONE Many times you get the time inthe local time zone, but you want to display the same time in UTC Time Zone. MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use a similar approach; however, we can use  CONVERT_TIMEZONE  as follows: For more details, refer to the  CONVERT_TIMEZONE  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 86 - Modulus/Modulo Function - Remainder

Image
Modulus/Modulo Function - Remainder While calculating, if you want to find the remainder, then we can use this. MS-SQL Server   We can achieve it as follows: In  Snowflake ,  we can use a similar approach; however, we can use  MOD  as follows: For more details, refer to the  MOD  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 85 - UNION ALL BY NAME

Image
        UNION ALL BY NAME Sometimes, we have to combine data from multiple tables. In this case, we can use UNION or UNION ALL. However, the catch is that the column order or the number of columns in both tables must be the same. MS-SQL Server   We can achieve this  using  UNION  as shown below,  specifying the column names. We cannot use (*) in the select clause as the number of columns and their names are different: In  Snowflake ,  we can use  the same query as above; however, we can use the  (*) in the select clause  with  UNION ALL BY NAME   as below. The order of the columns in the  select clause does not matter. For more details, you can refer to the following:  UNION_ALL_BY_NAME . Yogesh Shinde LinkedInProfile <<< Back   Next >>>    

Snowflake Vs MS-SQL - Part 84 - EXTRACT Day/Month/Year

Image
            EXTRACT Day/Month/Year Sometimes you have to extract Day or Month, or Year from a Date. MS-SQL Server   We can achieve it as follows: In  Snowflake,  we can use a similar approach; however, we can use  EXTRACT  as follows: Note: You can use EXTRACT to convert the timestamp to its  Unix epoch  time  representation as below: For more details, refer to the  EXTRACT  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>>

Snowflake Vs MS-SQL - Part 83 - Compare NULL - IS NOT DISTINCT FROM

Image
            Compare NULL - IS NOT DISTINCT FROM Sometimes you have to compare with NULL in the WHERE clause. MS-SQL Server   We can achieve it as below: In  Snowflake,  we can use a similar approach; however, we can use  IS NOT DISTINCT FROM   as below: For more details, refer to the  IS_NOT_DISTINCT_FROM  section. Yogesh Shinde LinkedInProfile <<< Back   Next >>>    

Snowflake Vs MS-SQL - Part 82 - Generate Unique Identifier

Image
            Generate Unique Identifier Sometimes, we need to generate a unique identifier and use it consistently throughout our code. MS-SQL Server   We can achieve it by using built-in functions as follows: In  Snowflake,  we can use a similar function,  UUID_STRING (),  as below : For more details, refer to the  UUID_STRING  section. Yogesh Shinde LinkedInProfile   <<< Back   Next >>>  

Snowflake Vs MS-SQL - Part 81 - First Day Of The Month - DATE_TRUNC

Image
            First Day Of The Month Suppose you calculate the first day of the month based on today's date. MS-SQL Server   We can achieve it by using built-in functions as below: In  Snowflake,  we can use a similar approach; however, we can use  DATE_TRUNC   as  below: This can also be used for Year & Week.  For more details, refer to the  DATE_TRUNC  section . Yogesh Shinde LinkedInProfile <<< Back   Next >>>