SQL shows it's age by having exactly the same problem. Queries should start by the `FROM` clause, that way which entities are involved can be quickly resolved and a smart editor can aid you in writing a sensible query faster. The order should be FROM -> SELECT -> WHERE, since SELECT commonly gives names to columns, which WHERE will reference. You could even avoid crap like `SELECT * FROM table`, and just write `FROM…
The order should be starting on FROM, followed by any sequences of whatever clauses (except for FROM), always creating an intermediary result-set. FROM table -- equivalent to today's select * from table SELECT a, 1 as b, c, d -- equivalent to select ... from table WHERE a in (1, 2, 3) -- the above with the where GROUP BY c -- the above with the group by WHERE sum(d) > 100 -- the above with having sum(d) > 100 SELECT…
You want the DB to first run SELECT * FROM , and then start operating on that?