To answer my own question, I think this is the correct solution: PREFIX CONSTRUCT { ... } WHERE { BIND () { SELECT ... WHERE { ... } GROUP BY ... } }
Best, Peter > -----Ursprüngliche Nachricht----- > Von: Wetz Peter [mailto:peter.w...@tuwien.ac.at] > Gesendet: Dienstag, 24. November 2015 11:24 > An: users@jena.apache.org > Betreff: BIND in CONSTRUCT query with sub-SELECT (SPARQL) > > Related to the answer of a previous question of mine (see [1]) I have a new > question: I currently have a CONSTRUCT query with a nested SELECT which > makes use of aggregates. What I now want to do is to construct new URIs in > the CONSTRUCT statement. > > What I want to do is basically similar as can be seen in [2]. There I see that > BIND is used in the WHERE class to construct new URIs which are then used in > the CONSTRUCT clause. Unfortunately this approach does not work for my > case (nested SELECT which resides in the CONSTRUCT's WHERE clause). The > difference is, that in this example no nested SELECT is present. > > My current query looks like this (simplified): > > PREFIXES > CONSTRUCT { ?s rdfs:label ?var . } > WHERE { > SELECT ?s (AVG(?single) as ?agg) ... > WHERE { > ... > } > GROUP BY ?s ... > } > > The question is: Where to place a BIND statement which is used to bind > values to variables, which are then used in the CONSTRUCT statement (e.g. > ?var)? > > Thanks for your help. > > Best, > Peter > > [1] https://mail-archives.apache.org/mod_mbox/jena- > users/201511.mbox/%3C19440356.622107.1446464087017.JavaMail.yahoo@ > mail.yahoo.com%3E > [2] http://mail-archives.apache.org/mod_mbox/jena- > users/201111.mbox/%3c4ed66723.7030...@googlemail.com%3E