how to create aggregation on a graph from CONSTRUCT
<p>This is my query:</p>

<pre><code>PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX rs: &lt;http://www.welovethesemanticweb.com/rs#&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
    construct {
  ?subject0 rs:similarityValue ?similairty0.
    ?subject1 rs:similarityValue ?similairty1
}
WHERE {

  {
  ?subject0 ?predicate0 ?object0.
  rs:Impromptu_No._1 ?predicate0 ?object0.
    ?predicate0 rs:hasSimilarityValue ?similairty0Helper.
    BIND(?similairty0Helper * (4/9) AS ?similairty0)
    FILTER (?subject0 != rs:Impromptu_No)  
  }
  union {
    ?subject1 ?predicate ?object.
    ?object ?predicate1 ?object1.
    ?predicate1 rs:hasSimilarityValue ?similairty1Helper.
    rs:Impromptu_No._1 ?predicateHelper ?objectHelper.
    ?objectHelper ?predicate1 ?object1
      BIND(?similairty1Helper * (1/9) AS ?similairty1)
    FILTER (?subject1 != rs:Impromptu_No._1)
  }
}
</code></pre>

<p>and the result is:</p>

<pre><code>rs:5th_Symphony
      rs:similarityValue
            0.011111111111111112e0 .

rs:Polonaise_heroique
      rs:similarityValue
            0.011111111111111112e0 , 0.17777777777777778e0 , 0.26666666666666666e0 .

rs:Preludes
      rs:similarityValue
            0.011111111111111112e0 , 0.26666666666666666e0 , 0.17777777777777778e0 .

rs:Requiem_Sequentia
      rs:similarityValue
            0.011111111111111112e0 .

rs:Le_nozze_di_Figaro
      rs:similarityValue
            0.011111111111111112e0 .

rs:Symphony_No._29_in_A_major
      rs:similarityValue
            0.011111111111111112e0 .

rs:Piano_Concerto_No._24
      rs:similarityValue
            0.011111111111111112e0 .

rs:Impromptu_No._1
      rs:similarityValue
            0.26666666666666666e0 , 0.17777777777777778e0 .

rs:Sonata_Pathetique
      rs:similarityValue
            0.011111111111111112e0 .

rs:Dies_Irae
      rs:similarityValue
            0.011111111111111112e0 .

rs:Piano_Sonata_No._31
      rs:similarityValue
            0.011111111111111112e0 , 0.26666666666666666e0 .

rs:Violin_Concerto_No._5_in_A_major
      rs:similarityValue
            0.011111111111111112e0 .
</code></pre>

<p>As you see, for each instance, there are many values, I want to aggregate them and make the <code>SUM</code> of them for each instance. I would do that with <code>SELECT</code>, but with <code>CONSTRUCT</code>, I didn't know how to apply the aggregation.</p>

<p>After reading, i found that we can't use the aggregation directly from <code>CONSTRUCT</code>, but i'd need to use <code>SELECT</code> and <code>CONSTRUCT</code> together, it seems i have to use something named "named graph" but i didn't know how to do that even i tried.</p>

<p>your help is highly appreciated.</p>

<p>Many thanks, best regards,</p>

<h3>Update 1</h3>

<p>One of the ways I've tried is:</p>

<pre><code>construct {
  ?subject0 rs:similarityValue ?similairty0.
    ?subject1 rs:similarityValue ?similairty1
}
WHERE {
  GRAPH ?g  {?subject0 rs:similarityValue ?similairty0}.
  {
  ?subject0 ?predicate0 ?object0.
....
</code></pre>

<p>but i got empty results</p>