query-7bb67fbc7f69f62fa0bb12a14ffd5c80

rq turtle/ttl

Languages and writing scripts by country of citizenship

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?country ?countryLabel (GROUP_CONCAT(DISTINCT ?lang; separator=', ') AS ?langs) (GROUP_CONCAT(DISTINCT ?scriptL; separator=', ') AS ?scripts) (COUNT(DISTINCT ?item) AS ?cnt) WHERE {
   {
  SELECT DISTINCT ?item WHERE {
    ?item p:P106/ps:P106/wdt:P279* wd:Q26270618
  }
}.
  ?item wdt:P27 ?country .
  OPTIONAL {
    ?country wdt:P37 ?language .
    ?language rdfs:label ?lang .
    FILTER(LANG(?lang) = 'en') .
    OPTIONAL {
      ?language wdt:P282 ?script .
      ?script rdfs:label ?scriptL .
      FILTER(LANG(?scriptL) = 'en') .
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?country ?countryLabel ORDER BY DESC(?cnt)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?cnt") v4("?country"):::projected v3("?item"):::projected v2("?lang"):::projected v8("?langs") v6("?language") v7("?script") v5("?scriptL"):::projected v9("?scripts") a1((" ")) a2((" ")) c11(["bd:serviceParam"]):::iri c5(["wd:Q26270618"]):::iri c1(["en"]):::literal v3 --"p:P106"--> a1 a1 --"p:statement/P106"--> a2 a2 --"p:direct/P279"--> c5 v3 --"p:direct/P27"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P37".-> v6 v6 --"rdfs:label"--> v2 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P282".-> v7 v7 --"rdfs:label"--> v5 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c1 end bind3[/"?lang"/] v2 --o bind3 bind3 --as--o v8 bind4[/"?scriptL"/] v5 --o bind4 bind4 --as--o v9 bind5[/"count(?item)"/] v3 --o bind5 bind5 --as--o v10