query-f05fa34ed9b58add1fee914173c489c1

rq turtle/ttl

title:English Wikipedia articles about Booker winners and nominees (books) SELECT DISTINCT ?item ?itemLabel ?awardLabel ?rel ?enwp WHERE { hint:Query hint:optimizer "None" . VALUES ?award{wd:Q160082 wd:Q2052291} { ?item wdt:P166 ?award. BIND("won" AS ?rel) } UNION{?item p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) } UNION{?item p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010563 BIND("longlist" AS ?rel) } MINUS{?item wdt:P31 wd:Q5} OPTIONAL { ?item wdt:P629 ?work . ?work_enwp schema:about ?work ; schema:isPartOf https://en.wikipedia.org/ } OPTIONAL { ?item_enwp schema:about ?item ; schema:isPartOf https://en.wikipedia.org/} BIND(COALESCE(?item_enwp, ?work_enwp) AS ?enwp) 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 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:English Wikipedia articles about Booker winners and nominees (books)
SELECT DISTINCT ?item ?itemLabel ?awardLabel ?rel ?enwp WHERE {

  VALUES ?award{wd:Q160082 wd:Q2052291}
 { ?item wdt:P166 ?award. BIND("won" AS ?rel) }
UNION{?item p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) }
UNION{?item p:P1411 ?s. ?s ps:P1411 ?award. ?s pq:P1552 wd:Q115010563 BIND("longlist" AS ?rel) }
  MINUS{?item wdt:P31 wd:Q5}
OPTIONAL { ?item wdt:P629 ?work . ?work_enwp schema:about ?work ; schema:isPartOf <https://en.wikipedia.org/> }
OPTIONAL { ?item_enwp schema:about ?item ; schema:isPartOf <https://en.wikipedia.org/>}
BIND(COALESCE(?item_enwp, ?work_enwp) AS ?enwp)
    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") v9("?enwp"):::projected v3("?item"):::projected v1("?itemLabel"):::projected v8("?item_enwp") v6("?rel"):::projected v5("?s") v6("?work") v7("?work_enwp") c6(["wd:Q115010563"]):::iri c12([https://en.wikipedia.org/]):::iri c14(["bd:serviceParam"]):::iri c8(["wd:Q5"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal c5(["wd:Q115010579"]):::iri 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; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v3 --"p:P1411"--> v5 v5 --"p:statement/P1411"--> v2 v5 --"p:qualifier/P1552"--> c6 bind1[/"'longlist'"/] bind1 --as--o v6 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"p:P1411"--> v5 v5 --"p:statement/P1411"--> v2 v5 --"p:qualifier/P1552"--> c5 bind2[/"'shortlist'"/] bind2 --as--o v6 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P166"--> v2 bind3[/"'won'"/] bind3 --as--o v6 end union0r <== or ==> union0l end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> c8 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P629".-> v6 v7 --"schema:about"--> v6 v7 --"schema:isPartOf"--> c12 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."schema:about".-> v3 v8 --"schema:isPartOf"--> c12 end bind5[/"?item_enwp?work_enwp"/] v8 --o bind5 v7 --o bind5 bind5 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end