query-7b88842508f58ae5772f7543c98f0df4

rq turtle/ttl

Cemetery Burials with coordinates and sitelink count SELECT ?item ?itemLabel ?itemDescription ?location ( COUNT( ?sitelink ) AS ?sitelink_count ) WHERE { ?item wdt:P31 wd:Q5. #instance of human ?item wdt:P119 wd:Q6723847. #place of burial, insert cemetery qid here OPTIONAL{?item p:P119 [ ps:P119 ?placeburial; pq:P625 ?location ].} #return the coordinate location qualifier of place of burial if it exists ?sitelink schema:about ?item. #get site links SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } #default label thing Optional{?item schema:description"en".} #get English description } GROUP BY ?item ?itemLabel ?location ?itemDescription #group items, if other field are to be shown they need to be added to this HAVING ( COUNT( ?sitelink ) > 0 ) #only show if there is at least 1 sitelink ORDER BY DESC( COUNT( ?sitelink ) ) #sort by number of sitelinks for each item

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Cemetery Burials with coordinates and sitelink count
SELECT 
  ?item 
  ?itemLabel
  ?itemDescription
  ?location
  ( COUNT( ?sitelink ) AS ?sitelink_count ) 
WHERE 
{
  ?item wdt:P31 wd:Q5. #instance of human
  ?item wdt:P119 wd:Q6723847. #place of burial, insert cemetery qid here
  OPTIONAL{?item p:P119 [ ps:P119 ?placeburial; pq:P625 ?location ].} #return the coordinate location qualifier of place of burial if it exists
  ?sitelink schema:about ?item. #get site links
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } #default label thing
  Optional{?item schema:description"en".} #get English description
}
GROUP BY ?item ?itemLabel ?location ?itemDescription #group items, if other field are to be shown they need to be added to this
HAVING ( COUNT( ?sitelink ) > 0 ) #only show if there is at least 1 sitelink
ORDER BY DESC( COUNT( ?sitelink ) ) #sort by number of sitelinks for each item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?_anon_42b5416610844a34809f33a099ae9de126670") v6("?_anon_42b5416610844a34809f33a099ae9de126671") v1("?item"):::projected v3("?location"):::projected v2("?placeburial") v4("?sitelink"):::projected v7("?sitelink_count") a3((" ")) a2((" ")) a1((" ")) c15(["en"]):::literal c11(["bd:serviceParam"]):::iri c5(["wd:Q6723847"]):::iri c3(["wd:Q5"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[[" > '0^^xsd:integer'"]] f0 --> a2 v1 --"p:direct/P31"--> c3 v1 --"p:direct/P119"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; a3 -."p:statement/P119".-> v2 a3 --"p:qualifier/P625"--> v3 v1 --"p:P119"--> a3 end v4 --"schema:about"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."schema:description".-> c15 end bind4[/"count(?sitelink)"/] v4 --o bind4 bind4 --as--o v5 bind5[/"count(?sitelink)"/] v4 --o bind5 bind5 --as--o v6 bind6[/"count(?sitelink)"/] v4 --o bind6 bind6 --as--o v7