-
Notifications
You must be signed in to change notification settings - Fork 0
How to query a statement with Qualifiers and References in Wikidata
Let’s use a well-known item with qualifiers and references to ensure we get results. We’ll query for the population of Germany (Q183) with qualifiers for the point in time and the reference URL.
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?population ?pointInTime ?referenceUrl
WHERE {
wd:Q183 p:P1082 ?statement . # Germany (Q183) and its population statement
?statement ps:P1082 ?population . # The population value
OPTIONAL { ?statement pq:P585 ?pointInTime . } # The point in time as a qualifier
OPTIONAL {
?statement prov:wasDerivedFrom ?referenceNode .
?referenceNode pr:P854 ?referenceUrl . # The reference URL
}
}
LIMIT 10
wd: for Wikidata entities.
wdt: for direct properties in Wikidata.
p: for properties in the context of statements.
ps: for the main value of a statement.
pq: for qualifiers.
pr: for references.
prov: for provenance information.
?population: The population value.
?pointInTime: The point in time as a qualifier.
?referenceUrl: The reference URL.
wd:Q183 p:P1082 ?statement .: Finds the statement about the population of Germany (Q183).
?statement ps:P1082 ?population .: Retrieves the population value from the statement.
OPTIONAL { ?statement pq:P585 ?pointInTime . }: Optionally retrieves the point in time as a qualifier.
OPTIONAL { ?statement prov:wasDerivedFrom ?referenceNode . ?referenceNode pr:P854 ?referenceUrl . }: Optionally retrieves the reference URL.