query-5d1f14e433800c2f5f4dbd13da70dd16

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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#>
SELECT
  ?item ?itemLabel 
  (GROUP_CONCAT(DISTINCT ?autoreLabel; separator=", ") as ?performer_ )
  (MIN(YEAR(?data_premio_strega)) as ?prize_year ) 
  (GROUP_CONCAT(DISTINCT ?genreLabel; separator=", ") as ?genre_ ) 
  (GROUP_CONCAT(DISTINCT ?casa_editriceLabel; separator=", ") as ?Label_ ) 
  (GROUP_CONCAT(DISTINCT ?VIAFLabel; separator=", ") as ?Producer_ ) 

WHERE
{
    BIND( wd:Q84321390 as ?tipopremio )
    ?item  wdt:P166 ?tipopremio. MINUS { ?item wdt:P31 wd:Q5 } 
  # ?autore p:P166 ?st . ?st pq:P1686 ?itemĀ ; ps:P166 ?tipopremio . ?autore wdt:P31 wd:Q5 .
#alternativa2:  ?item  wdt:P166 ?tipopremio . hint:Prior hint:runFirst true . ?item  wdt:P31/wdt:P279* wd:Q47461344 . 
#alternativa:   ?autore p:P166 ?st . ?st pq:P1686 ?itemĀ ; ps:P166 ?tipopremio . ?autore wdt:P31 wd:Q5 .
    OPTIONAL { ?item p:P166 ?premio . ?premio pq:P585 ?data_premio_strega ; ps:P166 ?tipopremio } 
    OPTIONAL { ?item wdt:P577 ?pubblicazione. } 
    OPTIONAL { ?item wdt:P175 ?autore }  #nome dell'autore
    OPTIONAL { ?item wdt:P136 ?genre }  #genere del libro
    OPTIONAL { ?item wdt:P264 ?casa_editrice } #casa editrice
    OPTIONAL { ?item  wdt:P162 ?VIAF } #VIAF

    SERVICE wikibase:label { bd:serviceParam wikibase:language "it,[AUTO_LANGUAGE],en" .
                           # necessario per GROUP BY/GROUP_CONCAT: 
                           ?item rdfs:label ?itemLabel .
                           ?autore rdfs:label ?autoreLabel .
                           ?genre rdfs:label ?genreLabel .
                           ?casa_editrice rdfs:label ?casa_editriceLabel . 
                           ?VIAF rdfs:label ?VIAFLabel . 
                           }
}
GROUP BY ?item ?itemLabel 
ORDER BY ?data_premio_strega_

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v19("?Label_") v20("?Producer_") v10("?VIAF") v15("?VIAFLabel"):::projected v7("?autore") v12("?autoreLabel"):::projected v9("?casa_editrice") v14("?casa_editriceLabel"):::projected v5("?data_premio_strega"):::projected v1("?data_premio_strega_") v8("?genre") v13("?genreLabel"):::projected v18("?genre_") v3("?item"):::projected v11("?itemLabel"):::projected v16("?performer_") v4("?premio") v17("?prize_year") v6("?pubblicazione") v2("?tipopremio") c15(["it,#91;AUTO_LANGUAGE#93;,en"]):::literal c13(["bd:serviceParam"]):::iri c3(["wd:Q5"]):::iri bind0[/"'wd:Q84321390'"/] bind0 --as--o v2 v3 --"p:direct/P166"--> v2 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> c3 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P166".-> v4 v4 --"p:qualifier/P585"--> v5 v4 --"p:statement/P166"--> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P577".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P175".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P136".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P264".-> v9 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P162".-> v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 v3 --"rdfs:label"--> v11 v7 --"rdfs:label"--> v12 v8 --"rdfs:label"--> v13 v9 --"rdfs:label"--> v14 v10 --"rdfs:label"--> v15 end bind7[/"?autoreLabel"/] v12 --o bind7 bind7 --as--o v16 bind8[/"min(year-from-dateTime(?data_premio_strega))"/] v5 --o bind8 bind8 --as--o v17 bind9[/"?genreLabel"/] v13 --o bind9 bind9 --as--o v18 bind10[/"?casa_editriceLabel"/] v14 --o bind10 bind10 --as--o v19 bind11[/"?VIAFLabel"/] v15 --o bind11 bind11 --as--o v20