Koen Verbeeck notes that Snowflake DB aliasing is a bit more robust than SQL Server’s:
That’s right. I defined an expression – a concatenation of two fields – and used the alias of that expression in another expression. Furthermore, I used the alias of the second expression in the WHERE clause. Gasp.
My workaround is to use CROSS APPLY
and define calculations in blocks there. This doesn’t work for aggregation operations, but in cases like Koen’s example, it does simplify the SELECT
and WHERE
clauses. This is a nicer solution, though.