query-4298122a32e8729a8d723608eb7d8472
rq turtle/ttl
title:Booker Prize winners and nominees
SELECT ?book ?bookLabel ?authorLabel ?rel (YEAR(?time) as ?year) ?authorwp ?bookwp WHERE {
VALUES ?award{wd:Q160082}
{?book p:P166 ?s. ?s ps:P166 ?award BIND("won" AS ?rel). MINUS{?book wdt:P31 wd:Q5} }
UNION{?book p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} }
UNION{?book p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010563 BIND("longlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} }
OPTIONAL {?s pq:P585 ?time}
OPTIONAL {?book wdt:P629?/wdt:P50 ?author
OPTIONAL {?authorwp schema:about ?author; schema:isPartOf https://en.wikipedia.org/ }
}
OPTIONAL {?bookwp schema:about ?book; schema:isPartOf https://en.wikipedia.org/ }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?year ?awardLabel DESC(?rel)
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 schema: <http://schema.org/>
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 winners and nominees
SELECT ?book ?bookLabel ?authorLabel ?rel (YEAR(?time) as ?year) ?authorwp ?bookwp WHERE {
VALUES ?award{wd:Q160082}
{?book p:P166 ?s. ?s ps:P166 ?award BIND("won" AS ?rel). MINUS{?book wdt:P31 wd:Q5} }
UNION{?book p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} }
UNION{?book p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010563 BIND("longlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} }
OPTIONAL {?s pq:P585 ?time}
OPTIONAL {?book wdt:P629?/wdt:P50 ?author
OPTIONAL {?authorwp schema:about ?author; schema:isPartOf <https://en.wikipedia.org/> }
}
OPTIONAL {?bookwp schema:about ?book; schema:isPartOf <https://en.wikipedia.org/> }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?year ?awardLabel DESC(?rel)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?author")
v9("?authorwp"):::projected
v4("?award")
v2("?awardLabel")
v5("?book"):::projected
v10("?bookwp"):::projected
v7("?rel"):::projected
v6("?s")
v7("?time"):::projected
v11("?year")
a1((" "))
c9(["wd:Q115010563"]):::iri
c15([https://en.wikipedia.org/]):::iri
c17(["bd:serviceParam"]):::iri
c4(["wd:Q5"]):::iri
c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c8(["wd:Q115010579"]):::iri
bind0[/VALUES ?award/]
bind0-->v4
bind00(["wd:Q160082"])
bind00 --> bind0
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v5 --"p:P1411"--> v6
v6 --"p:statement/P1411"--> v4
v6 --"p:qualifier/P1552"--> c9
bind1[/"'longlist'"/]
bind1 --as--o v7
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P31"--> c4
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v5 --"p:P1411"--> v6
v6 --"p:statement/P1411"--> v4
v6 --"p:qualifier/P1552"--> c8
bind3[/"'shortlist'"/]
bind3 --as--o v7
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P31"--> c4
end
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v5 --"p:P166"--> v6
v6 --"p:statement/P166"--> v4
bind5[/"'won'"/]
bind5 --as--o v7
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v5 --"p:direct/P31"--> c4
end
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:qualifier/P585".-> v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
v5 -."p:direct/P629".-> a1
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
end
union2r <== or ==> union2l
end
a1 --"p:direct/P50"--> v8
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v9 -."schema:about".-> v8
v9 --"schema:isPartOf"--> c15
end
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v10 -."schema:about".-> v5
v10 --"schema:isPartOf"--> c15
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
end
bind7[/"year-from-dateTime(?time)"/]
v7 --o bind7
bind7 --as--o v11