query-ad831b90a08eb83fd6371c5d2c680d8f

rq turtle/ttl

It’s practical an enhancement of the already existing queries in the example section. So first we search for all universities in the country X i.e.Mauritius. We want to know in which city the university is based and which degree and major is granted. At last we gave the opportunity to filter for special towns, degrees and majors. This way it is possible to find a specific degree with a specific major in a city within a country. The third question is about some statistics. (How many universities do award a specific degree or a specific major in a country?) It should show for a specific country a little overview about how many degrees or majors of the same kind do exist. After a few difficulties we finally managed to create the query.

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#>
SELECT ?degreeLabel (COUNT(DISTINCT ?item) AS ?count) WHERE {
    { ?item wdt:P31 wd:Q3918. }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "en".}
    OPTIONAL { ?item wdt:P17 ?country; 
                 p:P5460 ?statement .
?statement ps:P5460 ?degree .
    ?statement pq:P812 ?major .}
FILTER(?country = wd:Q1027 ) #Mauritius
}
GROUP BY ?degreeLabel ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?count") v2("?country") v5("?degree") v3("?item"):::projected v6("?major") v4("?statement") c5(["bd:serviceParam"]):::iri c7(["en"]):::literal c3(["wd:Q3918"]):::iri f0[["?country = 'wd:Q1027'"]] f0 --> v2 v3 --"p:direct/P31"--> c3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P17".-> v2 v3 --"p:P5460"--> v4 v4 --"p:statement/P5460"--> v5 v4 --"p:qualifier/P812"--> v6 end bind2[/"count(?item)"/] v3 --o bind2 bind2 --as--o v7