Thread: Re: [HACKERS] SELECT ... AS ... names in WHERE/GROUP BY/HAVIN G

Re: [HACKERS] SELECT ... AS ... names in WHERE/GROUP BY/HAVIN G

From
Zeugswetter Andreas SB
Date:
> Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
> > Informix and DB/2 allow column numbering in the group by clause.
> 
> What do they do with
> 
>     SELECT foo AS bar FROM table GROUP BY bar
> 
> What do they do if bar is the real name of another column in 
> the table?

They don't allow labels, only numbers, 
(SELECT foo AS bar FROM table GROUP BY 1)

In the special case where a label collides with a colname,
we need to use the colname, because that behavior is 
ruled by the standard (since it doesn't allow a label).

The order by clause is the other way around.

DB Vendors probably disallow this syntax,
because the two different interpretations would be a bit awkward.

Best would of course be if the standard allowed labels in the 
group by and where clause and take label before colname.

Andreas