Snowflake Interval Data Types and Conversion Examples

The INTERVAL data types in Snowflake are handy and widely used types when working with date, time variables. Snowflake supports interval types in the same way as other PostgreSQL databases such as Netezza, Redshift, Vertica, Oracle, etc. In this article, we will check interval types with some common use cases. Snowflake Interval Data Types You can express interval types as a combination of the INTERVAL keyword with a numeric quantity and a supported date part; for example: INTERVAL '1 days' or INTERVAL '10 minutes'. The Snowflake INTERVAL functions are commonly…

Continue ReadingSnowflake Interval Data Types and Conversion Examples
Comments Off on Snowflake Interval Data Types and Conversion Examples

Snowflake Merge Statement Syntax, Usage and Examples

In a data warehouse, it is common to manipulate the table data. Sometimes, you have to manipulate the source table using data from another table. Many relational databases such as Netezza supports Merge command that can perform update/delete, or delete simultaneously. In this example, we will check how to manipulate table using Snowflake Merge statement with some example. Snowflake Merge Statement The merge command in SQL is a command that allows you to update, delete, or insert into a source table using target table. Based on the matching condition rows…

Continue ReadingSnowflake Merge Statement Syntax, Usage and Examples
Comments Off on Snowflake Merge Statement Syntax, Usage and Examples

Snowflake Reuse Computed column – Derived Columns

The derived columns in Snowflake are columns that are derived from the previously calculated columns in same SELECT statement. In this article, we will check how to reuse previously computed or calculated column in Snowflake. These kind of columns are sometime called lateral column alias. What are derived columns? Derived columns or computed columns are virtual columns that are not physically stored in the table. Their values are re-calculated every time they are referenced in a query. In other word, Derived columns are columns that you derive from other previously…

Continue ReadingSnowflake Reuse Computed column – Derived Columns
Comments Off on Snowflake Reuse Computed column – Derived Columns

Snowflake Split String on Delimiter-Functions and Examples

The split string is one of the common requirements in many relational database and programming languages. For example, get username from the string. Many RDBMS provides the functions or methods to split string on a delimiter and extract required text from an array. In this article, we will check Snowflake functions to split string on a delimiter. Snowflake Split String In many relational databases such as Netezza, PostgreSQL, etc, you can use array functions to extract records from split string result. But, Snowflake supports many useful split functions that you…

Continue ReadingSnowflake Split String on Delimiter-Functions and Examples
Comments Off on Snowflake Split String on Delimiter-Functions and Examples

How to Export Snowflake Data to JSON Format? -Example

The JSON format is one of the widely used file formats to store data that you want to transmit to another server or location. Most of the web applications use JSON to exchange the application information. For example, provide parameter values, credentials, etc. In this article, we will check how to export Snowflake data to json format with some examples. What is JSON file? Before jumping into the methods to export Snowflake table in JSON format, first, let us check what is JSON file? The JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. One…

Continue ReadingHow to Export Snowflake Data to JSON Format? -Example
Comments Off on How to Export Snowflake Data to JSON Format? -Example

Snowflake Extract Function Usage and Examples

The extract function in Snowflake extracts specified date or time part from the date, time, or timestamp fields. This function retrieves the sub part such as day, month, year,etc. The extract function is equivalent to date_part() function. In this article, we will check how to use extract and date_part function to get specified sub part. Snowflake Extract Function The extract function is very useful when you are working with various data sources. Sometimes, you may get requirement to extract part of timestamp field such as date and pass it to…

Continue ReadingSnowflake Extract Function Usage and Examples
Comments Off on Snowflake Extract Function Usage and Examples

Snowflake Recover Deleted Rows – Time Travel Examples

The Snowflake cloud data warehouse works with heterogeneous data sets. You may work with huge amount of data. It is a common requirement to recover the deleted rows or records. During the clean up process, the developer may delete the data accidentally. In this article, we will check how to recover deleted rows in Snowflake using time travel settings. Snowflake Recover Deleted Rows As mentioned, you can recover the deleted records. Snowflake uses the time travel setting to store the historical data. Snowflake Time Travel The Snowflake Time Travel enables…

Continue ReadingSnowflake Recover Deleted Rows – Time Travel Examples
Comments Off on Snowflake Recover Deleted Rows – Time Travel Examples

Snowflake Pad Zeros – LPAD and RPAD with Examples

Snowflake supports many useful string functions. The pad functions are most commonly used string functions in databases. The Snowflake pad functions are commonly used to pad characters such as zeros. You can use the pad functions to add or remove the characters either at the beginning or end of an expression or column values. In this article, we will Snowflake pad functions such as LPAD and RPAD with an example to pad zeros. Snowflake Pad Functions As mentioned earlier, Snowflake supports a lot of string manipulation functions. Among them, the…

Continue ReadingSnowflake Pad Zeros – LPAD and RPAD with Examples
Comments Off on Snowflake Pad Zeros – LPAD and RPAD with Examples

Snowflake Update Join Syntax – Update using other Table

In the database, data is stored in the tables. Data is collected from various sources. Data is collected over the specific period of time and it may or may not be accurate at the time of loading. In some cases, you may want to update the table by taking data from other another table over same or other database on the same server. In this article, we will check Snowflake Update Join Syntax and example on how to update a table with data from another table. Snowflake Update Join Table…

Continue ReadingSnowflake Update Join Syntax – Update using other Table
Comments Off on Snowflake Update Join Syntax – Update using other Table

Snowflake Cumulative SUM and AVERAGE – Examples

Most of the analytical databases such as Netezza, Teradata, Oracle, Vertica allow you to use windows function to calculate running total or average. In this article, we will check how to use analytic functions with windows specification to calculate Snowflake Cumulative Sum (running total) or cumulative average with some examples. Snowflake Cumulative SUM and AVERAGE The cumulative sum or running total is one of the interesting problems in the databases where you have to calculate the sum or average using current result and previous (or next) row value. Snowflake Cumulative…

Continue ReadingSnowflake Cumulative SUM and AVERAGE – Examples
Comments Off on Snowflake Cumulative SUM and AVERAGE – Examples