> Next question is, do we want to leave the code as-is, or tighten up
> the parser to reject AS-names and column numbers in GROUP BY?
The numbers are also allowed in other DBMS's, so I would leave that as is.
> It seems to me we should change it, because there are cases where the
> existing code will do the wrong thing according to the SQL spec.
> If "foo" is a column name and also an AS-name for something else,
> "GROUP BY foo" should group on the raw column according to the spec,
> but right now we will pick the SELECT result value instead.
This of course should be handeled the other way around.
Imho the feature to use the AS-names is too convenient,
to drop it alltogether. Remember, that the lable could stand for
a complete subselect, and writing the same subselect again and
again is quite bad for readability.
I would rather extend this AS-names capability to the where
and having clause too.
select
(select max(colname) from syscolumns cwhere c.tabid = systables.tabid) as collabel
from systables
where tabname='systables' and collabel matches 'n*';
is imho a very nice and readable syntax .
Andreas