title: Sparql Keys vs distinct values
body: <p>I have a sparql query that returns duplicates, and I want it to clean them up on one of the values only (subjectID). Unlike DISTINCT that seems to find a unique value for the combination of values selected, rather than for only one of the parameters.
  I saw someone here propose group by, but that only seems applicable if I list all the parameters after group by (my sparql endpoint complains, e.g. Non-group key variable in SELECT: ?occupation).
  I tried running an internal select, but it doesn't seem to work for this specific query. So might be an issue with the query itself ( the values of the livedIn optional seem to be causing the duplicate) ? </p>
  
  <p>While happy enough with relational DBs early in the learning curve with SPARQL, so feel free to explain the obvious for the otherwise uninitiated! :)</p>
  
  <pre><code>select distinct  
    ?subjectID ?englishName ?sex ?locatedIn15Name 
    ?dob ?dod ?dom ?bornLocationName ?occupation 
    where { 
        ?person a hc:Person ;
        hc:englishName ?englishName ;
        hc:sex ?sex; 
        hc:subjectID ?subjectID; 
         optional { ?person hc:livedIn11 ?livedIn11 .
             ?livedIn11 hc:englishName ?lived11LocationName . 
             ?livedIn11 hc:locatedIn11 ?locatedIn11 .
             ?locatedIn11 hc:englishName ?locatedIn11Name .
             ?locatedIn11 hc:locatedIn15 ?locatedIn15 .
   ?locatedIn15 hc:englishName ?locatedIn15Name .
   } . 
         optional {?person hc:born ?dob } .
         optional {?person hc:dateOfDeath ?dod } .
         optional {?person hc:dateOfMarriage ?dom } .
         optional { ?person hc:bornIn ?bornIn . 
         ?bornIn hc:englishName ?bornLocationName . 
               ?bornIn hc:easting ?easting . 
               ?bornIn hc:northing ?northing } .
         optional {  ?person hc:occupation ?occupation } 
         FILTER regex(?englishName, "^FirstName LastName")
        } 
    GROUP BY 
    ?subjectID ?englishName  ?sex 
     ?locatedIn15Name ?dob ?dod ?dom 
    ?bornLocationName ?occupation 
  </code></pre>