query-6f2479032eab17c8876fd8f6f2f71369

rq turtle/ttl

title:Booker Prize winners and nominees: authors SELECT ?item ?itemLabel ?workLabel ?rel ?awardLabel (YEAR(?time) as ?year) WHERE { VALUES ?award{wd:Q160082 wd:Q2052291} {?item p:P166 ?s. ?s ps:P166 ?award BIND("won" AS ?rel). ?item wdt:P31 wd:Q5} UNION {?item p:P1411 ?s .?s ps:P1411 ?award BIND("nominated" AS ?rel). ?item wdt:P31 wd:Q5} OPTIONAL {?s pq:P585 ?time} OPTIONAL {?s pq:P1686 ?work} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } ORDER BY ?year ?awardLabel ?rel

Use at

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 winners and nominees: authors
SELECT ?item ?itemLabel ?workLabel ?rel ?awardLabel (YEAR(?time) as ?year) WHERE {
  VALUES ?award{wd:Q160082 wd:Q2052291}
  {?item p:P166 ?s. ?s ps:P166 ?award BIND("won" AS ?rel). ?item wdt:P31 wd:Q5}
UNION {?item p:P1411 ?s .?s ps:P1411 ?award BIND("nominated" AS ?rel). ?item wdt:P31 wd:Q5}
  OPTIONAL {?s pq:P585 ?time}
  OPTIONAL {?s pq:P1686 ?work}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?year ?awardLabel ?rel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?award") v2("?awardLabel"):::projected v5("?item"):::projected v7("?rel"):::projected v6("?s") v7("?time"):::projected v8("?work") v9("?year") c10(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?award/] bind0-->v4 bind00(["wd:Q160082"]) bind00 --> bind0 bind01(["wd:Q2052291"]) bind01 --> bind0 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:P1411"--> v6 v6 --"p:statement/P1411"--> v4 bind1[/"'nominated'"/] bind1 --as--o v7 v5 --"p:direct/P31"--> c4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:P166"--> v6 v6 --"p:statement/P166"--> v4 bind2[/"'won'"/] bind2 --as--o v7 v5 --"p:direct/P31"--> c4 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; v6 -."p:qualifier/P1686".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind3[/"year-from-dateTime(?time)"/] v7 --o bind3 bind3 --as--o v9