query-9df56d3bf71fce0fdafe5c7b2315d2e3

rq turtle/ttl

TODO

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
  ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?partyLabel) AS ?partyLabel)
  (GROUP_CONCAT(REPLACE(?districtLabel_, "kieskring", ""); SEPARATOR="; ") AS ?districts)
  (GROUP_CONCAT(?rank_; SEPARATOR=", ") AS ?ranks) (SUM(?votes_) AS ?votes)
WHERE {
  ?node ps:P3602 wd:Q42733725;
    ^p:P3602 ?item.

  OPTIONAL { ?node pq:P1268 ?party. }
  OPTIONAL { ?node pq:P768 ?district_. }
  OPTIONAL { ?node pq:P4243 ?rank_. }
  OPTIONAL { ?node pq:P1111 ?votes_. }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "nl,en".
    ?item rdfs:label ?itemLabel.
    ?party rdfs:label ?partyLabel.
    ?district_ rdfs:label ?districtLabel_.
  }
}
GROUP BY ?item
ORDER BY ?partyLabel DESC(?votes)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?districtLabel_"):::projected v6("?district_") v11("?districts") v4("?item"):::projected v11("?itemLabel"):::projected v3("?node") v5("?party") v11("?partyLabel"):::projected v7("?rank_"):::projected v12("?ranks") v13("?votes") v8("?votes_"):::projected c11(["nl,en"]):::literal c9(["bd:serviceParam"]):::iri c2(["wd:Q42733725"]):::iri v3 --"p:statement/P3602"--> c2 v4 --"p:P3602"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P1268".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P768".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P4243".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P1111".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 v4 --"rdfs:label"--> v11 v5 --"rdfs:label"--> v11 v6 --"rdfs:label"--> v10 end bind5[/"sample(?itemLabel)"/] v11 --o bind5 bind5 --as--o v11 bind6[/"sample(?partyLabel)"/] v11 --o bind6 bind6 --as--o v11 bind7[/"replace(?districtLabel_,'kieskring','')"/] v10 --o bind7 bind7 --as--o v11 bind8[/"?rank_"/] v7 --o bind8 bind8 --as--o v12 bind9[/"sum(?votes_)"/] v8 --o bind9 bind9 --as--o v13