On Sep 5, 2015 4:10 PM, "Darko Volaric" <lists at darko.org> wrote: > > That's not true. SQLite doesn't have to discard that information after > performing the substitutions. It can use it later for optimizations. > > I know that SQLite allows it. I'm not complaining about anything. Have a > look at my original question, which is, restated: > > What is the rationale behind disallowing using aliases in the body of > statements?
While I agree that it is can be useful, the primary reason I can think of for disallowing it is preventing gratuitous incompatibilities between SQL engines. This is particularly true when there are two options that can give the same effect: expressing the select-from as a query vs a table name (something like): select * from (select a as b from c) where b is something Or with a common table expression which I have so little experience with so far that I'm not going to try to write an example on my phone. :) All this being said, and without the experience of having written a SQL engine personally, it sure feels like the standardization committee got this wrong. It is such an intuitive way of thinking of using aliases that it should be part of the standard. I only know from past experience with other SQL products that it doesn't work in other places.