Forum Discussion
How to filter initial data pull using today's date as a reference for another column
- 2 years ago
sql doesn't use iif statements for the record
your where clause could look something like this.
assuming you can do a cte (common table expression) in snowflake
with cte_fiscal as (
select
max(FIS_YR_ID) as max_year
from
tablename
where
day = dateadd('day', -1, currentdate())
)
select
*
from
tablename
cross join cte_fiscal cte
where
FIS_YR_ID >= max_year -2
and FIS_YR_ID <= max_year
Good to know, thank you vanessafvg! I couldn't tell which brand of SQL they were writing, since this is a Microsoft Forum I assumed T-SQL which does support IIF.
i have never written an iif statement in sql, and ive done sql development for over 25 years 🙂 sql uses a case statement for if.
- SamWiseOwl2 years agoSuper User
Ahh so Case is better performance than IIF ? That is good to know thank you! vanessafvg Always happy for advice from the masters.
One that blew my mind was dragging the columns in the results pane, when was that added 🤔😂