query-b6abd0a42d0a2e537c8f21d0d23ed29c

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)applies to jurisdiction (P1001)position held (P39)start time (P580)end time (P582)

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 DISTINCT ?country ?countryLabel ?office ?officeLabel ?person ?personLabel
WHERE {    
  ?country wdt:P31 wd:Q185441 .            # for all EU member states
  OPTIONAL {
    ?office wdt:P279* wd:Q4018482 ;        #   find any subclass of "finance minister"
            wdt:P1001 ?country .           #   with that jurisdiction
    OPTIONAL {
      ?person p:P39 ?posn ; wdt:P31 wd:Q5 .  # find all humans with a position
      ?posn ps:P39 ?office ;                 # of that office
            pq:P580 ?start_date .            # where the position statement has a start date
      OPTIONAL { ?posn pq:P582 ?end_date }  # but with no end date
      FILTER ( !bound(?end_date) || isBLANK(?end_date) ) . 
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY ?countryLabel ?officeLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?country"):::projected v1("?countryLabel"):::projected v4("?end_date") v5("?office"):::projected v2("?officeLabel"):::projected v6("?person"):::projected v7("?posn") v8("?start_date") c14(["en"]):::literal c4(["wd:Q4018482"]):::iri c2(["wd:Q185441"]):::iri c12(["bd:serviceParam"]):::iri c7(["wd:Q5"]):::iri v3 --"p:direct/P31"--> c2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P279".-> c4 v5 --"p:direct/P1001"--> v3 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P39".-> v7 v6 --"p:direct/P31"--> c7 v7 --"p:statement/P39"--> v5 v7 --"p:qualifier/P580"--> v8 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P582".-> v4 end end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end