title: SPARQL query fetch properties of resources
body: <p>I have a triple store and would like to create a query. This is an example of a resource representing a single deed:</p>
  
  <pre><code>&lt;http://natarchives.com.mt/deed/MS588-D52&gt;
      locah:accessProvidedBy  &lt;http://natarchives.com.mt/repository/MT01&gt; ;
      locah:associatedWith    "heredes" , "honorabilis" , "uncias" , "per tactum penne" , "vinea" , "ut moris est" , "juribus" , "unciarum" , "precij" , "spacium" , "gracia" , "tabernam sitam" , "honorabili" , "renunciantes" , "territorio" , "testes" , "tarenos" , "recuperacionis consuetudinarie" , "positam" , "ponderis" , "post" , "tabernam" , "causa" , "per se" , "sed sponte jure" , "diaconus" , "cisterna" , "precio" , "civitate" , "festo" , "solvere" ;
      locah:associatedWith    &lt;http://natarchives.com.mt/person/person11817&gt; , &lt;http://natarchives.com.mt/person/person11826&gt; , &lt;http://natarchives.com.mt/person/person11822&gt; , &lt;http://natarchives.com.mt/person/person11820&gt; , &lt;http://natarchives.com.mt/person/person11823&gt; , &lt;http://natarchives.com.mt/person/person11818&gt; , &lt;http://natarchives.com.mt/place/place486&gt; , &lt;http://natarchives.com.mt/person/person11824&gt; , &lt;http://natarchives.com.mt/person/person11825&gt; , &lt;http://natarchives.com.mt/person/person11821&gt; , &lt;http://natarchives.com.mt/person/person11816&gt; , &lt;http://natarchives.com.mt/place/place886&gt; , &lt;http://natarchives.com.mt/person/person11819&gt; ;
      locah:level             &lt;http://data.archiveshub.ac.uk/page/level/item&gt; ;
      dcterms:date            "1-10-1467" ;
      dcterms:identifier      "MS588-D52" ;
      dcterms:isPartOf        &lt;http://natarchives.com.mt/archivalresource/MS588&gt; ;
      dcterms:type            "Emptio" .
  </code></pre>
  
  <p>I am trying to search the deed by date. The result should show:</p>
  
  <p>deed id, type, register URI - in this case (<a href="http://natarchives.com.mt/archivalresource/MS588" rel="nofollow noreferrer">http://natarchives.com.mt/archivalresource/MS588</a>), register Id, repository URI (<a href="http://natarchives.com.mt/repository/MT01" rel="nofollow noreferrer">http://natarchives.com.mt/repository/MT01</a>), repository name, keywords associated with the deed and the people and places associated with deed. For people and places I would like to get other properties such as name, surname. This is what I have so far:</p>
  
  <pre><code>PREFIX dcterms: &lt;http://purl.org/dc/terms/&gt;
  PREFIX locah: &lt;http://data.archiveshub.ac.uk/def/&gt;
  PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
  PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
  PREFIX schema: &lt;http://schema.org/&gt;
  SELECT  ?id ?type ?register ?regId ?rep ?repName ?associatedEntities                       
  WHERE                                                                          
  {
   {
      {
    SELECT ?id ?type ?register ?regId ?rep ?repName (group_concat(concat(str(?places)," @ ",?placeName); separator=" | ") as ?associatedEntities) 
    WHERE {
      ?x dcterms:date "22-1-1487".
      ?x dcterms:identifier ?id.
      ?x dcterms:type ?type.
      ?x locah:associatedWith ?places.
      ?places schema:name ?placeName.
      ?x dcterms:isPartOf ?register.
      ?register dcterms:identifier ?regId.
      ?x locah:accessProvidedBy ?rep.
      ?rep rdfs:label ?repName.
      FILTER (isURI(?places)).
      }
  GROUP BY ?id ?type ?register ?regId ?rep ?repName
  }union{
       SELECT ?id ?type ?register ?regId ?rep ?repName (group_concat(concat(str(?persons)," @ ",?name); separator=" | ") as ?associatedEntities) 
    WHERE {
      ?x dcterms:date "22-1-1487".
      ?x dcterms:identifier ?id.
      ?x dcterms:type ?type.
      ?x locah:associatedWith ?persons.
      ?persons foaf:firstName ?name.
      ?x dcterms:isPartOf ?register.
      ?register dcterms:identifier ?regId.
      ?x locah:accessProvidedBy ?rep.
      ?rep rdfs:label ?repName.
      FILTER (isURI(?persons)).
      }
        GROUP BY ?id ?type ?register ?regId ?rep ?repName
      }
  
    }
  
  }
  </code></pre>
  
  <p>I managed to get both but is it possible to group the results of the union</p>