Peter, A pragmatic way would be to use a nested SELECT first, where you can define aggregates that you would latter use in CONSTRUCT as usual.
Regards,Milorad From: Martynas Jusevičius <marty...@graphity.org> To: users@jena.apache.org Sent: Monday, November 2, 2015 12:23 PM Subject: Re: use aggregates in CONSTRUCT query You can, but they need to go in the WHERE part, not CONSTRUCT. And you need to GROUP BY first: http://rdf.myexperiment.org/howtosparql?page=GROUP%20BY On Mon, Nov 2, 2015 at 12:20 PM, Wetz Peter <peter.w...@tuwien.ac.at> wrote: > This is more of a SPARQL question, so sorry, if it not perfectly fits here: > I wonder, if it's possible to use aggregates in SPARQL CONSTRUCT queries. > > For instance, I have the following query: > > CONSTRUCT { > ?s ei:number ?number . > } > FROM <http://example.org> > WHERE { > ?s ei:number ?number > } > > However, since `?number` has multiple solutions, I would like to calculate > the aggregate. I tried it like this: > > CONSTRUCT { > ?s ei:number AVG(?number) . > } > FROM <http://example.org> > WHERE { > ?s ei:number ?number > } > > The [SPARQL Query Validator][1] raises the following error: > > Encountered " "avg" "AVG "" at line 3, column 14. > Was expecting one of: > ... > "true" ... > "false" ... > ... > "(" ... > ... > "[" ... > > Hence, my question is: (How) can I use aggregates in SPARQL CONSTRUCT queries > efficiently?