query-3c33308c23a65e96f12535ac79a277c5
Government Organizations (and subclasses)
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 skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item
?Label_en
?Description_en
(group_concat(distinct ?Alias_en;separator="; ") as ?Aliases_en) #Concatenate the values in order not to get several rows per item.
?Label_de
?Description_de
(group_concat(distinct ?Alias_de;separator="; ") as ?Aliases_de)
(replace(group_concat(distinct ?Type;separator="; "), "http://www.wikidata.org/entity/", "") as ?Types) #Strip the path in order to get only the Q-number.
(group_concat(distinct ?TypeLabel_en;separator="; ") as ?TypeLabels_en)
(replace(group_concat(distinct ?Municipality;separator="; "), "http://www.wikidata.org/entity/", "") as ?Municipalities)
(group_concat(distinct ?MunicipalityLabel_de;separator="; ") as ?MunicipalityLabels_de)
(replace(group_concat(distinct ?Canton;separator="; "), "http://www.wikidata.org/entity/", "") as ?Cantons)
(group_concat(distinct ?CantonLabel_de;separator="; ") as ?CantonLabels_de)
WHERE {
{?item wdt:P31/wdt:P279* wd:Q2659904 }
{?item wdt:P131/wdt:P17 wd:Q39 }.
OPTIONAL { ?item rdfs:label ?Label_en . FILTER (lang(?Label_en) = "en") }
OPTIONAL { ?item rdfs:label ?Label_de . FILTER (lang(?Label_de) = "de") }
OPTIONAL { ?item skos:altLabel ?Alias_en . FILTER (lang(?Alias_en) = "en") }
OPTIONAL { ?item skos:altLabel ?Alias_de . FILTER (lang(?Alias_de) = "de") }
OPTIONAL { ?item schema:description ?Description_en . FILTER (lang(?Description_en) = "en") }
OPTIONAL { ?item schema:description ?Description_de . FILTER (lang(?Description_de) = "de") }
OPTIONAL { ?item wdt:P31 ?Type. }
OPTIONAL { ?item wdt:P31/rdfs:label ?TypeLabel_en . FILTER (lang(?TypeLabel_en) = "en") }
OPTIONAL { ?item wdt:P131 ?Municipality . FILTER EXISTS {?Municipality wdt:P31 wd:Q70208} }
OPTIONAL { ?item wdt:P131/rdfs:label ?MunicipalityLabel_de . FILTER EXISTS {?MunicipalityLabel_de ^rdfs:label/wdt:P31 wd:Q70208} . FILTER (lang(?MunicipalityLabel_de) = "de") }
OPTIONAL { ?item wdt:P131 ?Canton . FILTER EXISTS {?Canton wdt:P31 wd:Q23058} }
OPTIONAL { ?item wdt:P131/rdfs:label ?CantonLabel_de . FILTER EXISTS {?CantonLabel_de ^rdfs:label/wdt:P31 wd:Q23058} . FILTER (lang(?CantonLabel_de) = "de") }
OPTIONAL { ?item wdt:P17 ?Country. }
OPTIONAL { ?item wdt:P17/rdfs:label ?CountryLabel_de . FILTER (lang(?CountryLabel_de) = "de") }
SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
group by ?item #List all the variables for which the values are not concatenated!
?Label_en ?Description_en
?Label_de ?Description_de
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?Alias_de"):::projected
v10("?Alias_en"):::projected
v20("?Aliases_de")
v19("?Aliases_en")
v3("?Canton")
v2("?CantonLabel_de"):::projected
v26("?CantonLabels_de")
v25("?Cantons")
v15("?Country")
v1("?CountryLabel_de")
v7("?Description_de"):::projected
v8("?Description_en"):::projected
v11("?Label_de"):::projected
v12("?Label_en"):::projected
v23("?Municipalities")
v5("?Municipality")
v4("?MunicipalityLabel_de"):::projected
v24("?MunicipalityLabels_de")
v14("?Type")
v6("?TypeLabel_en"):::projected
v22("?TypeLabels_en")
v21("?Types")
v16("?_anon_42b5416610844a34809f33a099ae9de1100854"):::projected
v17("?_anon_42b5416610844a34809f33a099ae9de1100855"):::projected
v18("?_anon_42b5416610844a34809f33a099ae9de1100856"):::projected
v13("?item"):::projected
a3((" "))
a4((" "))
a5((" "))
a6((" "))
a2((" "))
a7((" "))
a1((" "))
a8((" "))
c1(["de"]):::literal
c4(["wd:Q23058"]):::iri
c11(["wd:Q39"]):::iri
c8(["wd:Q2659904"]):::iri
c15(["bd:serviceParam"]):::iri
c5(["wd:Q70208"]):::iri
v13 --"wdt:P31"--> a3
a3 --"wdt:P279"--> c8
v13 --"wdt:P131"--> a4
a4 --"wdt:P17"--> c11
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v13 -."rdfs:label".-> v12
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v13 -."rdfs:label".-> v11
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v13 -."skos:altLabel".-> v10
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v13 -."skos:altLabel".-> v9
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v13 -."schema:description".-> v8
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v13 -."schema:description".-> v7
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P31".-> v14
end
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P31".-> a5
a5 --"rdfs:label"--> v6
end
subgraph optional8["(optional)"]
style optional8 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P131".-> v5
end
subgraph optional9["(optional)"]
style optional9 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P131".-> a6
a6 --"rdfs:label"--> v4
end
subgraph optional10["(optional)"]
style optional10 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P131".-> v3
end
subgraph optional11["(optional)"]
style optional11 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P131".-> a7
a7 --"rdfs:label"--> v2
end
subgraph optional12["(optional)"]
style optional12 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P17".-> v15
end
subgraph optional13["(optional)"]
style optional13 fill:#bbf,stroke-dasharray: 5 5;
v13 -."wdt:P17".-> a8
a8 --"rdfs:label"--> v1
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c1
end
bind8[/"?Type"/]
v14 --o bind8
bind8 --as--o v16
bind9[/"?Municipality"/]
v5 --o bind9
bind9 --as--o v17
bind10[/"?Canton"/]
v3 --o bind10
bind10 --as--o v18
bind11[/"?Alias_en"/]
v10 --o bind11
bind11 --as--o v19
bind12[/"?Alias_de"/]
v9 --o bind12
bind12 --as--o v20
bind13[/"replace(,'http://www.wikidata.org/entity/','')"/]
null --o bind13
bind13 --as--o v21
bind14[/"?TypeLabel_en"/]
v6 --o bind14
bind14 --as--o v22
bind15[/"replace(,'http://www.wikidata.org/entity/','')"/]
null --o bind15
bind15 --as--o v23
bind16[/"?MunicipalityLabel_de"/]
v4 --o bind16
bind16 --as--o v24
bind17[/"replace(,'http://www.wikidata.org/entity/','')"/]
null --o bind17
bind17 --as--o v25
bind18[/"?CantonLabel_de"/]
v2 --o bind18
bind18 --as--o v26