by joshka · 10y ago · 0 comments
SELECT
Foo,
Sum(Baz) AS Bar
FROM Quux
Use instead: SELECT
Foo,
Bar = Sum(Baz)
FROM Quux
The advantage here is that the names also line up neatly and the shape (column names etc.) of the result is obvious.It seems to me that sticking everything in CTEs would be equally as jarring. Writing SQL or reading and understanding someone else's SQL is almost always a non-linear process, not least of all because the processing order by the database engine isn't top-to-bottom.