query-efe4af33a44a9c671c8f4f335904f9c1

rq turtle/ttl

QueriesTo query the degrees and corresponding majors we added to the universities in Wikidata, we created a SPARQL 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 ?universityLabel ?degreeLabel ?majorLabel 
WHERE {
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    ?university wdt:P17 wd:Q33 ; #country is Finland
      wdt:P31 wd:Q875538 ; #instance of public university
      p:P5460 ?grants .
    ?grants ps:P5460 ?degree . #grants degree
    OPTIONAL { ?grants pq:P812 ?major .} #academic major
}
ORDER BY ?degreeLabel ?universityLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?degree") v1("?degreeLabel"):::projected v4("?grants") v6("?major") v3("?university") v2("?universityLabel"):::projected c2(["bd:serviceParam"]):::iri c4(["en"]):::literal c6(["wd:Q33"]):::iri c8(["wd:Q875538"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end v3 --"p:direct/P17"--> c6 v3 --"p:direct/P31"--> c8 v3 --"p:P5460"--> v4 v4 --"p:statement/P5460"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P812".-> v6 end