query-765f652dd962c8867c5933899ce33de5
List of countries (current+old)Hello, I'd like to enrich this query with the following needs :
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?pays #country
?paysLabel #countryname
(sample(?naturelabel) as ?nature)
(sample(?capitaleLabel) as ?capital)
?PaysPrecedentLabel #preceding country
(year(?Fondation) as ?AnneeFondation) #foundation year
(year(?Disparition) as ?AnneeDisparition) #disappearance year
?PaysRemplacantLabel #following country
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?pays (wdt:P31/wdt:P279*) wd:Q6256 .
OPTIONAL { ?pays wdt:P17 ?pays. }
OPTIONAL { ?pays wdt:P31 ?nature. }
OPTIONAL { ?pays wdt:P36 ?capitale. }
OPTIONAL { ?pays wdt:P1365 ?PaysPrecedent. }
OPTIONAL { ?pays wdt:P571 ?Fondation. }
OPTIONAL { ?pays wdt:P576 ?Disparition. }
OPTIONAL { ?pays wdt:P1366 ?PaysRemplacant. }
}
group by ?pays ?paysLabel ?PaysPrecedentLabel ?Fondation ?Disparition ?PaysRemplacantLabel
order by ?paysLabel ?Fondation
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?AnneeDisparition")
v12("?AnneeFondation")
v7("?Disparition"):::projected
v2("?Fondation"):::projected
v6("?PaysPrecedent")
v8("?PaysRemplacant")
v11("?capital")
v5("?capitale")
v10("?capitaleLabel"):::projected
v11("?nature")
v9("?naturelabel"):::projected
v3("?pays"):::projected
v1("?paysLabel"):::projected
a1((" "))
a2((" "))
c2(["bd:serviceParam"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["wd:Q6256"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v3 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
f0[["sameterm(?pays,)"]]
f0 --> v3
f0 --> a2
v3 -."wdt:P17".-> a2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P31".-> v11
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P36".-> v5
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P1365".-> v6
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P571".-> v2
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P576".-> v7
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P1366".-> v8
end
bind3[/"sample(?naturelabel)"/]
v9 --o bind3
bind3 --as--o v11
bind4[/"sample(?capitaleLabel)"/]
v10 --o bind4
bind4 --as--o v11
bind5[/"year-from-dateTime(?Fondation)"/]
v2 --o bind5
bind5 --as--o v12
bind6[/"year-from-dateTime(?Disparition)"/]
v7 --o bind6
bind6 --as--o v13