query-c68262816e2e4fb63c0580205232d648

rq turtle/ttl

title: Current list of French departments SELECT ?codeInsee ?item ?itemLabel ?itemDescription ?instance ?instanceLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } { wd:Q6465 ^(wdt:P279*) ?instance. ?item p:P31 ?typeStatement. ?typeStatement ps:P31 ?instance. FILTER(NOT EXISTS { ?typeStatement pq:P582 _:b2. }) } UNION { ?item p:P31 ?typeStatement. ?typeStatement ps:P31 wd:Q22923920; pq:P2868 wd:Q6465. } ?item wdt:P2586 ?codeInsee } ORDER BY (?codeInsee)

Use at

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#>
#title: Current list of French departments
SELECT ?codeInsee ?item ?itemLabel ?itemDescription ?instance ?instanceLabel  WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
{
wd:Q6465 ^(wdt:P279*) ?instance.
?item p:P31 ?typeStatement.
?typeStatement ps:P31 ?instance.
FILTER(NOT EXISTS { ?typeStatement pq:P582 _:b2. })
}
UNION
{
?item p:P31 ?typeStatement.
?typeStatement ps:P31 wd:Q22923920;
pq:P2868 wd:Q6465.
}
?item wdt:P2586 ?codeInsee
}
ORDER BY (?codeInsee)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?codeInsee"):::projected v3("?instance"):::projected v4("?item"):::projected v2("?typeStatement") a1((" ")) c2(["bd:serviceParam"]):::iri c10(["wd:Q22923920"]):::iri c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q6465"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v4 --"p:P31"--> v2 v2 --"p:statement/P31"--> c10 v2 --"p:qualifier/P2868"--> c7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0a1 e0v1("?typeStatement"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c5 f0 --> a1 v2 --"p:qualifier/P582"--> a1 v3 --"p:direct/P279"--> c7 v4 --"p:P31"--> v2 v2 --"p:statement/P31"--> v3 end union0r <== or ==> union0l end v4 --"p:direct/P2586"--> v1