query-87d3fcd319708fa3ee47acbd41c90939
TODO
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 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#>
SELECT ?item ?itemLabel ?population ?year ?population10 ?year10
WHERE
{
?item wdt:P31 wd:Q2074737;
(wdt:P131*) wd:Q93366.
?item p:P1082 ?pop.
?pop ps:P1082 ?population.
?pop pq:P585 ?date.
?pop wikibase:rank wikibase:PreferredRank.
BIND(YEAR(?date) as ?year).
BIND (?year - 10 AS ?years_minus_10)
OPTIONAL
{
?item p:P1082 ?pop10.
?pop10 ps:P1082 ?population10.
?pop10 pq:P585 ?date10.
BIND(YEAR(?date10) as ?year10).
FILTER (?year10 = ?years_minus_10)
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?date")
v10("?date10")
v3("?item"):::projected
v4("?pop")
v8("?pop10")
v5("?population"):::projected
v9("?population10"):::projected
v7("?year"):::projected
v11("?year10"):::projected
v8("?years_minus_10")
c2(["wd:Q2074737"]):::iri
c4(["wd:Q93366"]):::iri
c9(["wikibase:PreferredRank"]):::iri
c11(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v3 --"p:direct/P31"--> c2
v3 --"p:direct/P131"--> c4
v3 --"p:P1082"--> v4
v4 --"p:statement/P1082"--> v5
v4 --"p:qualifier/P585"--> v6
v4 --"wikibase:rank"--> c9
bind0[/"year-from-dateTime(?date)"/]
v6 --o bind0
bind0 --as--o v7
bind1[/"?year - '10^^xsd:integer'"/]
v7 --o bind1
bind1 --as--o v8
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:P1082".-> v8
v8 --"p:statement/P1082"--> v9
v8 --"p:qualifier/P585"--> v10
bind2[/"year-from-dateTime(?date10)"/]
v10 --o bind2
bind2 --as--o v11
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end