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

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.”

- Steve

-- 
Steve Harris, CTO, Garlik Limited
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10 9AD

Received on Wednesday, 14 December 2011 12:31:57 UTC