query-2d7c73fb1344ccc4ee566577643c1dda
Query
Use at
- https://query.wikidata.org/sparql
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?year (MAX(?population) as ?population) WHERE {
# set the item here - e.g. city, country
BIND(wd:Q84 as ?item)
?item p:P1082 ?popstatement .
?popstatement ps:P1082 ?population .
OPTIONAL {
?popstatement pq:P585 ?date .
BIND(year(?date) as ?year)
}
} GROUP BY ?year ?item ORDER BY ASC(?year)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?date")
v2("?item"):::projected
v3("?popstatement")
v6("?population"):::projected
v6("?year"):::projected
bind0[/"'wd:Q84'"/]
bind0 --as--o v2
v2 --"p:P1082"--> v3
v3 --"p:statement/P1082"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P585".-> v5
bind1[/"year-from-dateTime(?date)"/]
v5 --o bind1
bind1 --as--o v6
end
bind3[/"max(?population)"/]
v6 --o bind3
bind3 --as--o v6