User:Luckyz/SanremoWinners

From Wikidata
Jump to navigation Jump to search
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_
Try it!