DS Catalog:SPARQL Query Service/example queries: Difference between revisions

Jump to navigation Jump to search
Line 115: Line 115:
<syntaxhighlight lang="SPARQL">
<syntaxhighlight lang="SPARQL">
SELECT (COUNT(?string) AS ?stringCount)
SELECT (COUNT(?string) AS ?stringCount)
  #declared variable that will be counted and passed to another variable to display as a number


WHERE {
WHERE {
   ?stringStatement ps:P10 ?string . # use "as recorded" property P-value for the data you want to count
   ?stringStatement ps:P10 ?string .
    # use "as recorded" property P-value for the data you want to count
    
    
     SERVICE wikibase:label {
     SERVICE wikibase:label {
     bd:serviceParam wikibase:language "en" .
     bd:serviceParam wikibase:language "en" .
      # allows English language labels to be returned for Wikibase items
   }
   }
}
}
GROUP BY (?stringCount)
GROUP BY (?stringCount)
  # this sorts the results by number, and is necessary for COUNT clauses
</syntaxhighlight>
</syntaxhighlight>


Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits

Navigation menu