Today I learned about the SQL WITH
-statement. I’d been using CREATE VIEW
whenever I needed to join a complex query to itself; have I been doing it all wrong all these years?
If nothing else, WITH
is a lot more concise than what I had been doing, which was CREATE OR REPLACE TEMPORARY VIEW
. Are there arguments for the one versus the other, apart from concision?
P.S.: I’m told — haven’t confirmed — that if you join a table A
to itself using the WITH
-statement, then A
will be materialized just once, whereas it will be materialized twice under CREATE VIEW
.