query-cd5858c4dc5979d4290d8eee1c27a538
title:Booker Prize: authors nominated in multiple years SELECT ?item ?itemLabel (COUNT(?time) AS ?count) (GROUP_CONCAT(YEAR(?time); separator=", ") AS ?when) WHERE { VALUES ?award{wd:Q160082} ?item wdt:P31 wd:Q5 {?item p:P166 ?s. ?s ps:P166 ?award} UNION {?item p:P1411 ?s .?s ps:P1411 ?award} OPTIONAL {?s pq:P585 ?time} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } GROUP BY ?item ?itemLabel HAVING (?count > 1) ORDER BY DESC(?count)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
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#>
#title:Booker Prize: authors nominated in multiple years
SELECT ?item ?itemLabel (COUNT(?time) AS ?count) (GROUP_CONCAT(YEAR(?time); separator=", ") AS ?when) WHERE {
VALUES ?award{wd:Q160082}
?item wdt:P31 wd:Q5
{?item p:P166 ?s. ?s ps:P166 ?award}
UNION {?item p:P1411 ?s .?s ps:P1411 ?award}
OPTIONAL {?s pq:P585 ?time}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?item ?itemLabel HAVING (?count > 1)
ORDER BY DESC(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?award")
v6("?count")
v3("?item"):::projected
v4("?s")
v5("?time"):::projected
v6("?when")
c10(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?count > '1^^xsd:integer'"]]
f0 --> v6
bind1[/VALUES ?award/]
bind1-->v2
bind10(["wd:Q160082"])
bind10 --> bind1
v3 --"p:direct/P31"--> c3
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"p:P1411"--> v4
v4 --"p:statement/P1411"--> v2
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:P166"--> v4
v4 --"p:statement/P166"--> v2
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P585".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind4[/"count(?time)"/]
v5 --o bind4
bind4 --as--o v6
bind5[/"year-from-dateTime(?time)"/]
v5 --o bind5
bind5 --as--o v6