query-0f89e7c264f046e28cbfd5ee4ff72fc8

rq turtle/ttl

Select Member of Swiss National Council statement SELECT DISTINCT * WHERE { VALUES ?item { wd:Q117117 } # example item

# Select items that have P39 -> Q18510612, then select corresponding statements ?item wdt:P39 wd:Q18510612 .
?item p:P39 ?statement . FILTER EXISTS {?statement ?v wd:Q18510612 . }

OPTIONAL { ?statement pq:P768 ?canton . } OPTIONAL { ?statement pq:P580 ?start_time . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Select Member of Swiss National Council statement
SELECT DISTINCT *
WHERE 
{
  VALUES ?item { wd:Q117117 } # example item

  # Select items that have P39 -> Q18510612, then select corresponding *statements* 
  ?item wdt:P39 wd:Q18510612 .  
  ?item p:P39 ?statement .
  FILTER EXISTS {?statement ?v  wd:Q18510612 .  }

  OPTIONAL { ?statement pq:P768 ?canton . }
  OPTIONAL { ?statement pq:P580 ?start_time . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?canton"):::projected v3("?item"):::projected v5("?start_time"):::projected v1("?statement"):::projected v2("?v") c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal c1(["wd:Q18510612"]):::iri f0[[" "]] subgraph f0e0["Exists Clause"] e0v1 -->e0v2--> e0c1 e0v1("?statement"):::projected e0v2("?v"):::projected e0c1(["wd:Q18510612"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> v2 f0 --> c1 v1 -->v2--> c1 bind1[/VALUES ?item/] bind1-->v3 bind10(["wd:Q117117"]) bind10 --> bind1 v3 --"p:direct/P39"--> c1 v3 --"p:P39"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:qualifier/P768".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:qualifier/P580".-> v5 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end