query-6f74bde59a581a72d4c613e241c2bd1f

rq turtle/ttl

African countries, by language Wikipedia & language SELECT ?country ?countryLabel (group_concat(distinct ?itemLabel;separator="; ") as ?wikipedias) (group_concat(distinct ?languageLabel;separator="; ") as ?languages) WHERE { ?item wdt:P31 wd:Q10876391. # it's a language wikipedia ?item wdt:P407 ?language . # in this language ?language wdt:P17 ?country . # language is associated with country ?country wdt:P30 wd:Q15 . # country is in the continent of Africa SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?item rdfs:label ?itemLabel . ?country rdfs:label ?countryLabel . ?language rdfs:label ?languageLabel .} # get labels for values } group by ?country ?countryLabel # show only one row per country order by ?countryLabel # sort the results

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 bd: <http://www.bigdata.com/rdf#>
#African countries, by language Wikipedia & language
SELECT ?country ?countryLabel (group_concat(distinct ?itemLabel;separator="; ") as ?wikipedias) (group_concat(distinct ?languageLabel;separator="; ") as ?languages)
WHERE 
{
  ?item wdt:P31 wd:Q10876391.     # it's a language wikipedia 
  ?item wdt:P407 ?language .      # in this language
  ?language wdt:P17 ?country .    # language is associated with country
  ?country wdt:P30 wd:Q15 .       # country is in the continent of Africa
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                         ?item rdfs:label ?itemLabel .
                         ?country rdfs:label ?countryLabel .
                         ?language rdfs:label ?languageLabel .}
                                  # get labels for values
} group by ?country ?countryLabel # show only one row per country
order by ?countryLabel            # sort the results

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?country"):::projected v1("?countryLabel"):::projected v2("?item") v5("?itemLabel"):::projected v3("?language") v6("?languageLabel"):::projected v8("?languages") v7("?wikipedias") c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q10876391"]):::iri c6(["wd:Q15"]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P407"--> v3 v3 --"wdt:P17"--> v4 v4 --"wdt:P30"--> c6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v2 --"rdfs:label"--> v5 v4 --"rdfs:label"--> v1 v3 --"rdfs:label"--> v6 end bind2[/"?itemLabel"/] v5 --o bind2 bind2 --as--o v7 bind3[/"?languageLabel"/] v6 --o bind3 bind3 --as--o v8