4 ms·
For any who want this kind of pipelining way-of-writing-SQL that has the benefit of existing in live production databases today, I highly, highly recommend look
by btown 5y ago
For any who want this kind of pipelining way-of-writing-SQL that has the benefit of existing in live production databases today, I highly, highly recommend looking into Postgres' and Snowflake's LATERAL JOIN keyword.
https://heap.io/blog/postgresqls-powerful-new-join-type-lateral https://heap.io/blog/postgresqls-powerful-new-join-type-late...
https://stackoverflow.com/questions/28550679/what-is-the-difference-between-lateral-join-and-a-subquery-in-postgresql https://stackoverflow.com/questions/28550679/what-is-the-dif...
https://docs.snowflake.com/en/sql-reference/constructs/join-lateral.html https://docs.snowflake.com/en/sql-reference/constructs/join-...
The TL;DR is that they allow you to reuse annotated and aggregated columns in an incredibly elegant way. Compared to OP's proposal, you still do need to start the query with what columns you want to come out at the end, and normal SQL weirdnesses still apply - but it's far, far, easier when writing massive analytics queries to see the flow of variables from one stage to another.