Re: Query review, part 2 (ACTION-546)

On Dec 9, 2011, at 6:24 AM, Steve Harris wrote:

>>> === 18.2.4.1
>>> 
>>> "If the GROUP BY keyword is used, or there is implicit grouping due to the use of aggregates in the projection..."
>>> Is it possible to have an implicit grouping based on the use of aggregates in only the HAVING clause, and not the projection?
>> 
>> Yes and no.
>> 
>> Observation: if you have just "HAVING aggregate", then there is no possible legal SELECT clause.
>> 
>> Only GROUP BY variables and aggregates would be legal
>> There aren't any GROUP BY variables and you are askign about none in projection.
>> 
>> SELECT * is illegal if there is an aggregate (implicit group).
>> 
>> So I hope the answer is "yes" and it just falls out there are no legal queries.
>> 
>> @@Steve?
> 
> Yes, I'm not sure if it's worth adding something about HAVING making grouping implicit or not.

Steve,

Did you see my followup to Andy about this? I said:

"""
It's a bit perverse, but wouldn't "SELECT (1 AS ?one)" be a valid projection for such a query?
"""

This might be a corner case, but I think it's possible, and so should probably be mentioned (or "the use of aggregates in the projection" simply generalized by removing "in the projection").

thanks,
.greg

Received on Wednesday, 14 December 2011 01:10:04 UTC