query-e2dc84f595544ce0616f039726717c49
Get qualifiers of statement with preferred rank is missing entirely. (P1082)population statistics for a set of jurisdictions. I'd like to find cases where the statement with the preferred rank (whatever would be returned with a normal query) is either outdated or missing a reference... or where the (P1082)population I'm trying to do some quality assurance on the My understanding is that to get statement qualifiers, I need to refer directly to the statement node, but doing so seems to bypass the mechanism for returning only the preferred statement, instead returning all of them. I can access the rank itself, but how do I filter down to just the statement with the highest rank? I don't care about 19th century population figures; I just want the latest/preferred ones. My working draft query is below.
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?jurisdiction ?jurisdictionLabel ?population ( year(?PiT) as ?year ) ?rank ?refURL
WHERE {
VALUES ?jurisdiction { wd:Q1904 wd:Q8686 wd:Q42651 wd:Q172 wd:Q5826 wd:Q514796 }
OPTIONAL {
?jurisdiction p:P1082 ?statementNode .
?statementNode ps:P1082 ?population .
?statementNode wikibase:rank ?rank .
OPTIONAL {
?statementNode pq:P585 ?PiT .
}
OPTIONAL {
?statementNode prov:wasDerivedFrom ?referenceNode .
?referenceNode pr:P854 ?refURL .
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?jurisdiction ?rank ?year