In your example, the only variable from WHERE which is used in
CONSTRUCT template is ?s, and you don't show how ?s is obtained. You
aggregate ?agg but you don't use it in the template.

A better example would yield a more definite answer.

On Tue, Nov 24, 2015 at 11:44 AM, Wetz Peter <peter.w...@tuwien.ac.at> wrote:
> Maybe a valid answer, however in my use case that wouldnt work, because I 
> want to bind a variable which is then used in the CONSTRUCT, but it's a new 
> (!) variable and not a variable which comes from the nested SELECT.
>
> Best
>
>> -----Ursprüngliche Nachricht-----
>> Von: Martynas Jusevičius [mailto:marty...@graphity.org]
>> Gesendet: Dienstag, 24. November 2015 11:38
>> An: users@jena.apache.org
>> Betreff: Re: BIND in CONSTRUCT query with sub-SELECT (SPARQL)
>>
>> The BIND could also be within the sub-SELECT, depends on the use case.
>>
>> On Tue, Nov 24, 2015 at 11:35 AM, Wetz Peter <peter.w...@tuwien.ac.at>
>> wrote:
>> > 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

Reply via email to