On 2011-12-14, at 01:07, Gregory Williams wrote:
> 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").
Yes, but I can just add HAVING to the list of things that makes a query level implicitly aggregated, right?
I've changed the text to:
â€œIf aggregates or HAVING are used in the query level, but the GROUP BY term is not used, then this is taken to be a single implicit group, to which all solutions belong.â€