query-2e208bd1752ff21d5f1d8df7d6f106f2

rq turtle/ttl

SPARQL query

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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 ?wikidata ?name_WD ?start_date ?term 
WHERE 
{
  ?wikidata p:P39 ?membership .
  ?membership ps:P39 wd:Q18558478 .
  FILTER NOT EXISTS { ?membership pq:P582 ?end }
  OPTIONAL { ?membership pq:P580 ?start_date }
  OPTIONAL { ?membership pq:P2937 ?term_Item }

  FILTER ( ?term_Item=wd:Q5487948 || BOUND(?start_date) ) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
                         ?wikidata rdfs:label ?name_WD .
                         ?term_Item rdfs:label ?term .}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?end") v3("?membership") v6("?name_WD"):::projected v2("?start_date"):::projected v7("?term"):::projected v1("?term_Item") v5("?wikidata"):::projected c9(["bd:serviceParam"]):::iri c5(["wd:Q18558478"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["(?term_Item = 'wd:Q5487948' || bound(?start_date))"]] f0 --> v1 f0 --> v2 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?end"):::projected e0v1("?membership"):::projected end f1--EXISTS--> f1e0 f1 --> v3 f1 --> c2 f1 --> v4 v3 --"p:qualifier/P582"--> v4 v5 --"p:P39"--> v3 v3 --"p:statement/P39"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P580".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P2937".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 v5 --"rdfs:label"--> v6 v1 --"rdfs:label"--> v7 end