query-08183475194069dc3f87bbb690bd3247

rq turtle/ttl

title:Booker Prize winners and nominees: authors web sites and social SELECT ?item ?itemLabel ?rel ?awardLabel (YEAR(?time) as ?year) ?web (URI(CONCAT("https://twitter.com/", ?twusername)) AS ?twitter) 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. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} } UNION{?item 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 {?item wdt:P856 ?web} OPTIONAL {?item wdt:P2002 ?twusername} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } ORDER BY ?year ?awardLabel DESC(?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 web sites and social
SELECT ?item ?itemLabel ?rel ?awardLabel (YEAR(?time) as ?year) ?web (URI(CONCAT("https://twitter.com/", ?twusername)) AS ?twitter) 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. ?s pq:P1552 wd:Q115010579 BIND("shortlist" AS ?rel) MINUS{?book wdt:P31 wd:Q5} }
UNION{?item 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 {?item wdt:P856 ?web}
OPTIONAL {?item wdt:P2002 ?twusername}
    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; v4("?award") v2("?awardLabel"):::projected v7("?book") v5("?item"):::projected v8("?rel"):::projected v6("?s") v8("?time"):::projected v11("?twitter") v10("?twusername"):::projected v9("?web"):::projected v11("?year") c9(["wd:Q115010563"]):::iri c14(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal c8(["wd:Q115010579"]):::iri 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; 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 v8 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v7 --"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 v8 subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v7 --"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 v8 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".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P856".-> v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P2002".-> v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end bind6[/"year-from-dateTime(?time)"/] v8 --o bind6 bind6 --as--o v11 bind7[/"concat('https://twitter.com/',?twusername)"/] v10 --o bind7 bind7 --as--o v11