title: How to do a COUNT in SPARQL
body: <p>Given this very simple model:</p>
  
  <pre><code>@prefix :        &lt;http://example.org/tags#&gt; .
  @prefix owl:     &lt;http://www.w3.org/2002/07/owl#&gt; .
  @prefix rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
  @prefix rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
  @prefix xsd:     &lt;http://www.w3.org/2001/XMLSchema#&gt; .
  
  :tag  rdf:type rdf:Property .
  
  :item1
        rdf:type owl:Thing ;
        :tag    "a"^^xsd:string .
  
  :item2
        rdf:type owl:Thing ;
        :tag    "a"^^xsd:string , "b"^^xsd:string .
  
  :item3
        rdf:type owl:Thing ;
        :tag    "a"^^xsd:string , "b"^^xsd:string , "c"^^xsd:string .
  </code></pre>
  
  <p>I am trying to get a list of the items and the count of tags that each has:</p>
  
  <pre><code>item  tagCount
  ===== ========
  item1 1
  item2 2
  item3 3
  </code></pre>
  
  <p>Here is my query:</p>
  
  <pre><code>SELECT ?item (count(?tag) as ?tagcount)
  WHERE {
       ?item :tag ?tag
  }
  </code></pre>
  
  <p>However it is returning:</p>
  
  <pre><code>item  tagCount
  ===== ========
        6
  </code></pre>
  
  <p>From what I have read, this should work.  I am using Jena 2.6.4</p>