I have to agree with Joe here. Any expression within an aggregate
operator invocation must be considered a pre-aggregate expression. The
fact that it does not reference columns of the table being aggregated
is irrelevant. To write it out explicitly:
select max(Twelve) from (select 12 as Twelve from T) as T;
Incidentally, the fact that the SQL language allows for such debates
as this is a direct result of its poor design. A language in which
aggregation was orthogonal to projection and extension would not
suffer from these type of interpretation problems. Such a language
exists (shameless plug) and is called D4. It is an 'Industrial D' as
described by C. J. Date and Hugh Darwen in The Third Manifesto. Try it
out at www.alphora.com.
Regards,
Bryn Rhodes