query-40c0f66644e23782ded68be47f7d6de4

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)country (P17)shares border with (P47)

Use at

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 ?countryLabel ?divisiontype ?divisiontypeLabel (COUNT(?division) AS ?total) (COUNT(?bordered) AS ?with_borders) WHERE {
?division wdt:P31 ?divisiontype.
?divisiontype wdt:P279 wd:Q10864048;
  wdt:P17 ?country.
OPTIONAL {?division wdt:P47 ?bordered. ?bordered wdt:P31 ?divisiontype}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?countryLabel ?divisiontype ?divisiontypeLabel
ORDER BY ?countryLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?bordered"):::projected v4("?country") v1("?countryLabel"):::projected v2("?division"):::projected v3("?divisiontype"):::projected v6("?total") v7("?with_borders") c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["wd:Q10864048"]):::iri v2 --"wdt:P31"--> v3 v3 --"wdt:P279"--> c3 v3 --"wdt:P17"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P47".-> v5 v5 --"wdt:P31"--> v3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end bind2[/"count(?division)"/] v2 --o bind2 bind2 --as--o v6 bind3[/"count(?bordered)"/] v5 --o bind3 bind3 --as--o v7