Relative Content

Tag Archive for sqlsnowflake-cloud-data-platform

Snowflake Dynamic query filter

I have a query like below where i look at status of my table execution status. Where i need to search for last 7 days of executions status and for next day based on current date. I want my date filter to be dynamic based on current date. Currently i am using a static filter. But looking to do this dynamically. Any suggestions. I tried with CURRENT_TIMESTAMP function but format what i am looking is different because i need to filter very specifically for 7am for dates filter always

Snowflake SQL – Conditional Lead(), to retrieve the next row only when a condition is met?

I am looking to retrieve the first “Sales_Date” for each “Account_ID”, however in my dataset there are entries where the first sales is actually not a sales as the product transacted is a sample and thus $0 revenue. For those entries I would like to skip it and take the next Sales Date as the first “Sales_Date”. I have attempted the below query but run into the issue where some transactions may contain both a sample and a actual product in the same transaction. This results in duplicate rows with the same Account_ID being retrieved in the output. I am not sure how to change the query to resolve this and get the “Desired Output” below.

Snowflake Macro Variables

I have a dataset that I need to work with, every month a new set of columns are added with various names but have the month and year in the middle of the column name. I.e.