How to combine two arrays in Snowflake?

Snowflake is the one of the databases that combines many useful functions from other relational databases such as Oracle, PostgreSQL, Teradata, etc. Like many other relational databases, Snowflake support many array functions. In this article, we will check how to combine/merge/concatenate two or more arrays in Snowflake. Combine Two Arrays in Snowflake Snowflake allows you to deal with many different kinds of data sets. For example, you can work with JSON, XML or array variables with an ease. As Snowflake integrates many heterogeneous data sets, you may get requirement such…

Continue ReadingHow to combine two arrays in Snowflake?
Comments Off on How to combine two arrays in Snowflake?

How to Get First Row of each Group in Snowflake?

In the data warehouse reporting, you will encounter many different scenarios. One of such scenario is to get first row of each group. For example, identify the department wise highest salary. In this article, we will check how to select or get first row of each group in Snowflake. Select First Record of each Group in Snowflake Selecting first row of each group in SQL is one of the common query in reporting. You need to use proper function that does not take much time to return results. Following are…

Continue ReadingHow to Get First Row of each Group in Snowflake?
Comments Off on How to Get First Row of each Group in Snowflake?

Snowflake Concat Function and Operator – Examples

The Snowflake cloud architecture supports data ingestion from multiple sources, hence it is a common requirement to combine data from multiple columns to come up with required results. You may also get a requirement to concatenate multiple strings before loading them to target table. For example, you may get requirement to combine state and city columns before loading data to the customer address table. In this article, we will check Snowflake CONCAT function, its Syntax and examples. We will also check how to combine two or more columns using Snowflake…

Continue ReadingSnowflake Concat Function and Operator – Examples
Comments Off on Snowflake Concat Function and Operator – Examples

Snowflake Array Functions – Syntax and Examples

It is very common practice to store values in the form of an array in the databases. Without a doubt, Snowflake supports many array functions. You can use these array manipulation functions to manipulate the array types. In this article, we will check how to work with Snowflake Array Functions, syntax and examples to manipulate array types. Snowflake Array Functions Following is the list of Snowflake array functions with brief descriptions: Array FunctionsDescriptionARRAY_AGGFunction returns the input values, pivoted into an ARRAY.ARRAY_APPENDThis function returns an array containing all elements from the…

Continue ReadingSnowflake Array Functions – Syntax and Examples
Comments Off on Snowflake Array Functions – Syntax and Examples

What are SELECT INTO Alternatives in Snowflake?

In my other post, I have discussed about what are different methods to create Snowflake table. There are many database specific syntaxes that are not supported in Snowflake yet. One of such syntax is SELECT INTO. The databases such as SQL Server, Reshift, Teradata, etc. supports SELECT INTO clause to create new table and insert the resulting rows from the query into it. In this article, we will check what are SELECT INTO alternatives in Snowflake with some examples. SELECT INTO Alternatives in Snowflake In the databases such as SQL…

Continue ReadingWhat are SELECT INTO Alternatives in Snowflake?
Comments Off on What are SELECT INTO Alternatives in Snowflake?

What are Different Methods to Create Snowflake Tables?

In my other posts, I have discussed on how to create Snowflake clustered tables, creating external tables in Snowflake, etc. In this article, we will check what are different methods to create Snowflake tables with some basic examples. Different Methods to Create Snowflake Tables During database development, developer create a table such as permanent, temporary or transient tables as per the requirement. Developers usually create tables using DDL such as “CREATE TABLE” statement. But, sometimes you may need to use different methods such as creating a copy of an existing…

Continue ReadingWhat are Different Methods to Create Snowflake Tables?
Comments Off on What are Different Methods to Create Snowflake Tables?

How to Duplicate or Clone SQL Tables – Methods

In an application development, there may be situations where you need to create a similar table of the table which is already present in the database. In other words, you need to create a duplicate or clone of the existing table. The methods to duplicate or clone SQL table vary from database to database. For example, data warehouse such as Snowflake, Redshift provide methods which are not present in any other databases. In this article, we will check basic methods that you can use to clone or duplicate SQL tables…

Continue ReadingHow to Duplicate or Clone SQL Tables – Methods
Comments Off on How to Duplicate or Clone SQL Tables – Methods

Different Methods to Create Redshift Tables – Examples

In my other posts, I have discussed various methods to create Redshift table from Spark DataFrame, Redshift Temporary tables, creating an index on Redshift tables, etc. In this article, we will check different methods and approach to create Amazon Redshift tables. We will also check differences between various methods to create tables in Redshift. Different Methods to Create Redshift Tables During development, developer create a table either permanently or temporarily as per the requirement. Developers usually create tables using DDL such as “CREATE TABLE” statement. But, sometimes you may need…

Continue ReadingDifferent Methods to Create Redshift Tables – Examples
Comments Off on Different Methods to Create Redshift Tables – Examples

SQL GROUPING SETS Alternative in Redshift

In my other articles, we have discussed GROUP BY with CUBE and GROUP BY ROLLUP alternatives. In this article, we will check this SQL GROUPING SETS alternative in Amazon Redshift with an example. The GROUPING SETS option in SQL gives you the ability to combine multiple GROUP BY clauses into one GROUP BY clause. The GROUPING SETS is one of the powerful GROUP BY extension. The group set is a set of dimension columns. Amazon Redshift does not support GROUPING SETS. SQL GROUPING SETS Alternative in Redshift GROUP BY GROUPING…

Continue ReadingSQL GROUPING SETS Alternative in Redshift
Comments Off on SQL GROUPING SETS Alternative in Redshift

SQL GROUP BY ROLLUP Function Alternative in Redshift

In my other articles, we have discussed GROUP BY with GROUPING SETS and GROUP BY with CUBE alternatives. In this article, we will check the SQL GROUP BY ROLLUP function alternative in Amazon Redshift. The relational databases such as Oracle, Teradata, etc. support GROUP BY ROLLUP function to group the result rows. However, Amazon Redshift does not support GROUP BY ROLLUP function. SQL GROUP BY ROLLUP Alternative in Redshift Similar to GROUP BY with CUBE, the GROUP BY ROLLUP is an extension of the GROUP BY clause that produces sub-total rows. Sub-total…

Continue ReadingSQL GROUP BY ROLLUP Function Alternative in Redshift
Comments Off on SQL GROUP BY ROLLUP Function Alternative in Redshift