GROUP question

Just checking - this going to be legal, isn't it?  It's an idiom that 
seems natural and people do use it:

SELECT (SAMPLE(?x) AS ?x)
{
   ... ?x ...
} GROUP BY ?groupKey


In other words, can I use ?x as a new variable because the inner one is 
hidden by the group.  It seems a natural thing to write in the SAMPLE case.

 From wiki/Potentially_bound it seems the answer is yes.  ?x is not 
potentially bound when used at the point "AS ?x"

The ?x in SAMPLE(?x) is a different ?x because aggregates happen before 
select expressions in modifier order.

The ordering is:
# Grouping
# Aggregates
# Select expressions
# Having
...

and so

# Aggregates
... at this point only GROUP BY vars + aggregates are visible. [1]
# Select expressions

[1] minor: and so the aggregates are assigned to temporary vars to be 
renamed in the select expressions?  Can't see how else it would work.

 Andy

Received on Thursday, 14 October 2010 10:07:37 UTC