ON Clause & Cross Join We use different joins to pull the records from multiple tables. We need to use the ON clause along with JOIN. What will happen if we don't use the ON clause? MS-SQL Server If we don't mention the ON clause, it throws an error. However, if we use the same column from the same table on both sides, it works as a cross-join. Also, if you mention condition as 1=1 in the ON clause, it treats as CROSS JOIN. However, in Snowflake, both above queries will work. Apart from this, if you don't mention the ON clause, it treats it as CROSS JOIN: Yogesh Shinde LinkedInProfile <<< Back Next >>>
INITCAP Sometimes we need to provide strings/lines in a specific format as per the client's request. Suppose you want to capitalize the first letter of each word in the string and all other letters appear in lowercase. It needs special treatment, known as InitCap (Initial Capitalisation). MS-SQL Server You can only achieve this differently. You need to write a function or couple of lines of code as below: In Snowflake , we don't need to write so many lines of code . We can use the inbuilt function INITCAP. Also, this function gives you the flexibility to provide a delimiter that INITCAP uses as a separators for words in the input expression. In the below example, 'q' is used as the delimiter. For more details, you can refer to the following INITCAP . Yogesh Shinde LinkedInProfile <<< Back Next >>>
UNION By Name Sometimes, we have to combine data from multiple tables. In this case, we can use UNION. However, the catch is that the order of the columns should be the same. MS-SQL Server We can achieve this by using UNION as below: In Snowflake, we can use the same query as above; however, we have to use the same column order in the select clause. However, we can use UNION BY Name as below. The order of the columns in the select clause does not matter. NOTE: Similarly, you can use UNION ALL BY NAME . For more details, you can refer to the following: UNION . Yogesh Shinde LinkedInProfile <<< Back Next >>>
Comments
Post a Comment