query-8db67a83a67d24c0d85105192ecf5e4c

rq turtle/ttl

title:Booker Prize winners that are also shown as nominated SELECT ?item ?itemLabel ?awardLabel WHERE { VALUES ?award{wd:Q160082 wd:Q2052291} { ?item wdt:P1411 ?award . ?item wdt:P166 ?award. MINUS {?item wdt:P31 wd:Q5} } UNION {?item p:P1411 ?s1. ?s1 ps:P1411 ?award.
?item p:P166 ?s2. ?s2 ps:P166 ?award. { ?s2 pq:P1686 ?work. ?s1 pq:P1686 ?work} UNION { ?s2 pq:P585 ?date. ?s1 pq:P585 ?date } } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } ORDER BY ?itemLabel

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 that are also shown as nominated
SELECT ?item ?itemLabel ?awardLabel WHERE {
  VALUES ?award{wd:Q160082 wd:Q2052291}
{
  ?item wdt:P1411 ?award . ?item wdt:P166 ?award. MINUS {?item wdt:P31 wd:Q5}
}
  UNION {?item p:P1411 ?s1. ?s1 ps:P1411 ?award.  
         ?item p:P166 ?s2. ?s2 ps:P166 ?award.
         { ?s2 pq:P1686 ?work. ?s1 pq:P1686 ?work} UNION { ?s2 pq:P585 ?date. ?s1 pq:P585 ?date  }
        }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?award") v7("?date") v3("?item"):::projected v1("?itemLabel"):::projected v4("?s1") v5("?s2") v6("?work") c12(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?award/] bind0-->v2 bind00(["wd:Q160082"]) bind00 --> bind0 bind01(["wd:Q2052291"]) bind01 --> bind0 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"p:P1411"--> v4 v4 --"p:statement/P1411"--> v2 v3 --"p:P166"--> v5 v5 --"p:statement/P166"--> v2 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v5 --"p:qualifier/P585"--> v7 v4 --"p:qualifier/P585"--> v7 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v5 --"p:qualifier/P1686"--> v6 v4 --"p:qualifier/P1686"--> v6 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P1411"--> v2 v3 --"p:direct/P166"--> v2 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> c4 end end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end