title: Counting in SPARQL
body: <p>Ok so i have this query</p>
  
  <pre><code>PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; 
  
  SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
  ?instance a &lt;http://dbpedia.org/ontology/Ambassador&gt; . 
  }
  </code></pre>
  
  <p>and the result is 286. Cool. Now I want to get the number of ambassadors that have <a href="http://dbpedia.org/property/name" rel="noreferrer">http://dbpedia.org/property/name</a> property. But</p>
  
  <pre><code>PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; 
  
  SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
  ?instance a &lt;http://dbpedia.org/ontology/Ambassador&gt; . 
  ?instance &lt;http://dbpedia.org/property/name&gt; ?name
  }
  </code></pre>
  
  <p>results in 533 :(. So it is counting more because there are people which have this property one or more times. But how do I get the number of ambassadors that have this property regardless of how many times they have it. Can you do this in a single query?</p>
  
  <p>Thanks.</p>