query-e57c11e3871570f56413541a99ad8be9

rq turtle/ttl

SPARQL query

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?Minister ?University ?Course ?ministerWD ?institution WHERE {
    ?ministerWD p:P39 ?ministerialPostStatement .
    ?ministerialPostStatement ps:P39 ?ministerialPost .
    ?ministerialPost wdt:P279* wd:Q83307 .
    ?ministerialPost wdt:P361 wd:Q112014
    OPTIONAL {
       ?ministerialPostStatement pq:P580 ?start_time
    }
    OPTIONAL {
        ?ministerWD p:P69 ?universityStatement .
        ?universityStatement ps:P69 ?institution .
        ?institution wdt:P31 ?possible_institutions
        OPTIONAL {
            ?universityStatement pq:P812 ?subject .      
        }
    }
    # FILTER (?start_time >= "2016-07-13"^^xsd:dat)
    FILTER (?start_time >= "1992-04-09"^^xsd:dat)
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?ministerWD rdfs:label ?Minister .
        ?subject rdfs:label ?Course .
        ?institution rdfs:label ?University
    }
    VALUES ?possible_institutions {
        wd:Q3918 # University
        wd:Q2581649 # Oxford college
        wd:Q1055028 # Cambridge college
        wd:Q5146929 # Durham college
    }
}
ORDER BY ?Minister DESC(?start_time)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?Course"):::projected v1("?Minister"):::projected v11("?University"):::projected v7("?institution"):::projected v3("?ministerWD"):::projected v5("?ministerialPost") v4("?ministerialPostStatement") v12("?possible_institutions") v2("?start_time") v9("?subject") v6("?universityStatement") c16(["en"]):::literal c5(["wd:Q83307"]):::iri c14(["bd:serviceParam"]):::iri c7(["wd:Q112014"]):::iri f0[["?start_time >= s1992-04-09^^<http://www.w3.org/2001/XMLSchema#dat>'"]] f0 --> v2 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> v5 v5 --"p:direct/P279"--> c5 v5 --"p:direct/P361"--> c7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P580".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P69".-> v6 v6 --"p:statement/P69"--> v7 v7 --"p:direct/P31"--> v12 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P812".-> v9 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 v3 --"rdfs:label"--> v1 v9 --"rdfs:label"--> v10 v7 --"rdfs:label"--> v11 end bind1[/VALUES ?possible_institutions/] bind1-->v12 bind10(["wd:Q3918"]) bind10 --> bind1 bind11(["wd:Q2581649"]) bind11 --> bind1 bind12(["wd:Q1055028"]) bind12 --> bind1 bind13(["wd:Q5146929"]) bind13 --> bind1