query-7b88842508f58ae5772f7543c98f0df4
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
- https://query.wikidata.org/sparql
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