0

Related to another question (see: SPARQL functions in CONSTRUCT/WHERE) where the answer leads to having a SPARQL CONSTRUCT query with a aggregate SELECT inside, I now would like to know how to use BIND in this construct.

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)?

I tried to do it similar as is shown in this message: http://mail-archives.apache.org/mod_mbox/jena-users/201111.mbox/%3C4ED66723.7030506@googlemail.com%3E. But the difference is, that there is no nested SELECT in this example.

Community
  • 1
  • 1
beta
  • 5,324
  • 15
  • 57
  • 99

1 Answers1

2

This query composition seems to work for me:

PREFIX
CONSTRUCT { ... }
WHERE {
    BIND () {
        SELECT ...
            WHERE {
            ...
            }
        GROUP BY ...
    } 
}
beta
  • 5,324
  • 15
  • 57
  • 99
  • There's nothing in the bind(...) part. What are you trying to bind? – Joshua Taylor Nov 24 '15 at 13:01
  • it's just there for simplicity. I try to bind variables from the inner select. I already got some solutions here: http://mail-archives.apache.org/mod_mbox/jena-users/201511.mbox/browser thanks for your help! – beta Nov 24 '15 at 14:15