Re:A Short Story About SQL’s Biggest Rival
by SPBS on Saturday October 10, 2020 @12:08AM
(#24736627)
Yeah it's mentioned in this blog post https://blog.jooq.org/2014/01/06/the-sql-languages-most-miss... that SQL is missing Common Column Expressions, and that using Common Table Expressions reuse columns is simply a band-aid fix over the lack of those.
For example, your example would have been more naturally expressed as
SELECT partcol1
FROM (tbl WITH partcol1 AS AVG(col1) OVER (PARTITION BY col2))
WHERE partcol1 > 10.0
So if I have a bunch of these and want a convenient way to work with the named columns, I have to wrap them into a common table expression:
So wordy.