Skip to content
Advertisement

Tag: snowflake-cloud-data-platform

How to do a join to get previous days values?

I want to join tables as follow: Report_Period Entity Tag Users Count Report_Period_M-1 Report_Period_D-1 … 2021-03-31 entity 1 X 471 2017-05-31 2021-03-18 … 2020-12-31 entity 2 A 135 2020-11-30 2021-03-18 … 2020-11-30 entity 3 X 402 2020-10-31 2021-03-18 … With a view containing Day – 1 results as follow : Report_Period Entity Tag Users Count Report_Period_D-1 2021-03-31 entity 1 X

SQL date scenario for getting previous month’s data to-date on the 1st of month, then drop last month

I’m trying to recreate an existing View in Snowflake (originally in SQL Server). I need to get last month’s data which is easy enough, but here’s the scenario: On 3-1-21, it should retrieve 2-1-21 to 3-1-21, but then starting on 3-2-21, it should only show 3-1-21 to-date, as our month end reporting goes out on the 1st of the month,

SQL Snowflake Column Condition Check

Basically, I am trying to write a query against a table such like the following. Here we have Plans of either Free, Plus or Premium (in the example below I only show free and plus plans). Is it possible to return records where an ID that was original a ‘Free’ plan has changed to either a ‘plus’ or ‘premium’? This

Setting rules for max() with strings

Each record in my table has a random selection of these strings, so it looks like I want to get the highest value of “fruit” for each record, except I want it to be sorted lower if it contains the string guava. This is the output that I’d like and I’m using Snowflake SQL output: Currently, I’m trying to do

How to automate a sql script in snowflake

I have a SQL script that transforms data for various tables in snowflake. I need to run this SQL code daily and I want to automate it somehow. I thought I could automate the SQL with ‘tasks’ in snowflake but ‘tasks’ are unable to run more than one single SQL statement and my code contains a multitude of SQL statements.

Advertisement