query-855c9b8e9d3b01e71f8bfa6e8dbb2dbb
TODO
Use at
- https://query.wikidata.org/sparql
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 ?autoreLabel_ )
# (MIN(YEAR(?pubblicazione)) as ?pubblicazione_ )
(MIN(YEAR(?data_premio_strega)) as ?data_premio_strega_ )
# (GROUP_CONCAT(DISTINCT ?genreLabel; separator=", ") as ?genreLabel_ )
# (GROUP_CONCAT(DISTINCT ?casa_editriceLabel; separator=", ") as ?casa_editriceLabel_ )
# (GROUP_CONCAT(DISTINCT ?VIAFLabel; separator=", ") as ?VIAF_ )
(GROUP_CONCAT(DISTINCT ?countryLabel; separator=", ") as ?country_ )
WHERE
{
BIND( wd:Q129372 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:P50 ?autore } #nome dell'autore
OPTIONAL { ?item wdt:P136 ?genre } #genere del libro
OPTIONAL { ?item wdt:P123 ?casa_editrice } #casa editrice
OPTIONAL { ?item wdt:P214 ?VIAF } #VIAF
OPTIONAL { ?item wdt:P17 ?country } #country
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 .
?country rdfs:label ?countryLabel .
}
}
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;
v10("?VIAF")
v7("?autore")
v13("?autoreLabel")
v9("?casa_editrice")
v15("?casa_editriceLabel")
v11("?country")
v16("?countryLabel"):::projected
v17("?country_")
v5("?data_premio_strega"):::projected
v17("?data_premio_strega_")
v8("?genre")
v14("?genreLabel")
v3("?item"):::projected
v12("?itemLabel"):::projected
v4("?premio")
v6("?pubblicazione")
v2("?tipopremio")
c16(["it,#91;AUTO_LANGUAGE#93;,en"]):::literal
c14(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
bind0[/"'wd:Q129372'"/]
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/P50".-> 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/P214".-> v10
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P17".-> 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
v9 --"rdfs:label"--> v15
v11 --"rdfs:label"--> v16
end
bind4[/"min(year-from-dateTime(?data_premio_strega))"/]
v5 --o bind4
bind4 --as--o v17
bind5[/"?countryLabel"/]
v16 --o bind5
bind5 --as--o v17