One of the things I like about Snowflake is it's not as strict about when clauses are made available to other clauses. For example in the following:
WITH tbl (name, age) as (
SELECT * FROM values ('david',10), ('tom',20)
)
select
name,
age,
year(current_timestamp())-age as birthyear
from
tbl
where
birthyear > 2010
I can use birthyear
in the WHERE
clause. This would be in constract to something like SQL Server, where the binding is much more strict, for example here. Is there any documentation about the binding order in Snowflake, or is generally 'loose' and the parser will figure things out for you?
Or, same as in MySQL5.7:
select
name,
age,
year(now())-age as birthyear
from
(select 'tom' name, 20 age union select 'david', 10) tbl
where birthyear > 2010
Unknown column 'birthyear' in 'where clause'