- From: Andy Seaborne <andy.seaborne@epimorphics.com>
- Date: Mon, 21 Nov 2011 14:50:08 +0000
- To: SPARQL Working Group <public-rdf-dawg@w3.org>
The current spec doesn't include the case of an aggregate expression in
an ORDER BY - it's just an oversight in the translation algorithm.
18.2.4.1 Grouping and Aggregation
"""
For each expression E in SELECT and each HAVING(E) in Q
"""
should be:
"""
For each expression E in SELECT, each HAVING(E) and ORDER BY in Q
"""
SELECT ?x
{ ?x :p ?v }
GROUP BY ?x
HAVING (sum(?v) > 5)
ORDER BY sum(?v)
SELECT ?x
{ ?x :p ?v }
GROUP BY ?x
HAVING (sum(?v) > 5)
ORDER BY count(*)
It allows ORDERing without needing to project a variable of the
aggregate expression.
The processing order is
group/agg -> having -> select expressions -> order by
so, like mention in HAVING, a mention in ORDER BY should be allowed.
(It sort of is by LC1 in the grammar because the grammar wasn't clear -
noted and needs fixing).
Andy
Received on Monday, 21 November 2011 14:50:41 UTC