query-000ef2904b54c580fd3ad857f376638e

rq turtle/ttl

: You need to get the label within the query to be able to sample() it. Here's one approach.Theklan@

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 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#>
#defaultView:BarChart
SELECT (year(?start) as ?year) (count(?uni) as ?count) (sample(?uniLabel) as ?label) WHERE {
  ?item wdt:P39 wd:Q28778415.
  ?item p:P39 ?elect.
  ?elect ps:P39 ?elect_ .
  ?elect pq:P2937 ?term .
  ?term wdt:P31 wd:Q106450751.
             ?term wdt:P580 ?start.
  ?item wdt:P69 ?uni.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
                         ?uni rdfs:label ?uniLabel.}
}
GROUP by ?uniLabel ?start

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?count") v2("?elect") v3("?elect_") v1("?item") v10("?label") v5("?start"):::projected v4("?term") v6("?uni"):::projected v7("?uniLabel"):::projected v8("?year") c2(["wd:Q28778415"]):::iri c7(["wd:Q106450751"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"p:direct/P39"--> c2 v1 --"p:P39"--> v2 v2 --"p:statement/P39"--> v3 v2 --"p:qualifier/P2937"--> v4 v4 --"p:direct/P31"--> c7 v4 --"p:direct/P580"--> v5 v1 --"p:direct/P69"--> v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 v6 --"rdfs:label"--> v7 end bind2[/"year-from-dateTime(?start)"/] v5 --o bind2 bind2 --as--o v8 bind3[/"count(?uni)"/] v6 --o bind3 bind3 --as--o v9 bind4[/"sample(?uniLabel)"/] v7 --o bind4 bind4 --as--o v10