query-4d1134f0bfebe5ba3cb8dbc728e649a1

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 ?directorLabel; separator=", ") as ?directorLabel_ )
  (MIN(YEAR(?pubblicazione)) as ?pubblicazione_ ) 
  (MIN(YEAR(?data_premio_strega)) as ?prize_year_ ) 
  (GROUP_CONCAT(DISTINCT ?genreLabel; separator=", ") as ?genreLabel_ ) 
  (GROUP_CONCAT(DISTINCT ?IMDbLabel; separator=", ") as ?IMDbLabel_ ) 
 (GROUP_CONCAT(DISTINCT ?countryLabel; separator=", ") as ?country_ ) 

WHERE
{
    BIND( wd:Q777921 as ?tipopremio )
    ?item  wdt:P166 ?tipopremio. 
    ?item wdt:P31 wd:Q11424  
  # ?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:P57 ?director }  #nome dell'autore
    OPTIONAL { ?item wdt:P136 ?genre }  #genere del libro
    OPTIONAL { ?item wdt:P123 ?casa_editrice } #casa editrice
    OPTIONAL { ?item  wdt:P345 ?IMDb } #IMDbLabel
    OPTIONAL { ?item  wdt:P495  ?country } #country

    SERVICE wikibase:label { bd:serviceParam wikibase:language "it,[AUTO_LANGUAGE],en" .
                           # necessario per GROUP BY/GROUP_CONCAT: 
                           ?item rdfs:label ?itemLabel .
                           ?director rdfs:label ?directorLabel .
                           ?genre rdfs:label ?genreLabel .
                           ?country rdfs:label ?countryLabel . 
                            ?IMDb rdfs:label ?IMDbLabel . 
                           }
}
GROUP BY ?item ?itemLabel 
ORDER BY ?prize_year_

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?IMDb") v16("?IMDbLabel"):::projected v20("?IMDbLabel_") v9("?casa_editrice") v11("?country") v15("?countryLabel"):::projected v21("?country_") v5("?data_premio_strega"):::projected v7("?director") v13("?directorLabel"):::projected v17("?directorLabel_") v8("?genre") v14("?genreLabel"):::projected v19("?genreLabel_") v3("?item"):::projected v12("?itemLabel"):::projected v4("?premio") v19("?prize_year_") v6("?pubblicazione"):::projected v18("?pubblicazione_") v2("?tipopremio") c16(["it,#91;AUTO_LANGUAGE#93;,en"]):::literal c14(["bd:serviceParam"]):::iri c3(["wd:Q11424"]):::iri bind0[/"'wd:Q777921'"/] bind0 --as--o v2 v3 --"p:direct/P166"--> v2 v3 --"p:direct/P31"--> c3 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/P57".-> 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/P123".-> v9 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P345".-> v10 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P495".-> v11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 v3 --"rdfs:label"--> v12 v7 --"rdfs:label"--> v13 v8 --"rdfs:label"--> v14 v11 --"rdfs:label"--> v15 v10 --"rdfs:label"--> v16 end bind7[/"?directorLabel"/] v13 --o bind7 bind7 --as--o v17 bind8[/"min(year-from-dateTime(?pubblicazione))"/] v6 --o bind8 bind8 --as--o v18 bind9[/"min(year-from-dateTime(?data_premio_strega))"/] v5 --o bind9 bind9 --as--o v19 bind10[/"?genreLabel"/] v14 --o bind10 bind10 --as--o v19 bind11[/"?IMDbLabel"/] v16 --o bind11 bind11 --as--o v20 bind12[/"?countryLabel"/] v15 --o bind12 bind12 --as--o v21