query-c9a9104d48c777b442757342843cd984

rq turtle/ttl

Alle Nationalrate nach Kanton und Amtszeit

SELECT DISTINCT ?item ?itemLabel ?cantonLabel ?start_time

SELECT DISTINCT ?item (COUNT(?start_time) AS ?nr_times) (GROUP_CONCAT(year(?start_time); separator=";") AS ?start_times) (GROUP_CONCAT(?cantonLabel; separator=";") AS ?cantons) (GROUP_CONCAT(?periodLabel; separator=";") AS ?periods) WHERE { ?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 . } OPTIONAL { ?statement pq:P2937 ?period . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". ?canton rdfs:label ?cantonLabel . ?period rdfs:label ?periodLabel . } } GROUP BY ?item

Use at

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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Alle Nationalrate nach Kanton und Amtszeit
# SELECT DISTINCT ?item ?itemLabel ?cantonLabel ?start_time
SELECT DISTINCT ?item (COUNT(?start_time) AS ?nr_times) 
  (GROUP_CONCAT(year(?start_time); separator=";") AS ?start_times) 
  (GROUP_CONCAT(?cantonLabel; separator=";") AS ?cantons)
  (GROUP_CONCAT(?periodLabel; separator=";") AS ?periods)
WHERE 
{
  ?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 . }
  OPTIONAL { ?statement pq:P2937 ?period . }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". 
                          ?canton rdfs:label ?cantonLabel  .
                          ?period rdfs:label ?periodLabel  .
                         }
}
GROUP BY ?item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?canton") v7("?cantonLabel"):::projected v11("?cantons") v3("?item"):::projected v9("?nr_times") v6("?period") v8("?periodLabel"):::projected v12("?periods") v5("?start_time"):::projected v10("?start_times") v1("?statement") v2("?v") c10(["#91;AUTO_LANGUAGE#93;,de"]):::literal c8(["bd:serviceParam"]):::iri 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 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 optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:qualifier/P2937".-> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v4 --"rdfs:label"--> v7 v6 --"rdfs:label"--> v8 end bind5[/"count(?start_time)"/] v5 --o bind5 bind5 --as--o v9 bind6[/"year-from-dateTime(?start_time)"/] v5 --o bind6 bind6 --as--o v10 bind7[/"?cantonLabel"/] v7 --o bind7 bind7 --as--o v11 bind8[/"?periodLabel"/] v8 --o bind8 bind8 --as--o v12