query-1496b1ee62f6faaaffb6e5e4d2b58cc9
11:18, 23 September 2016 (UTC) dosisEpì--Looks good.
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?author ?authorLabel ?item ?itemLabel ?genreLabel ?date ?year ?title
{
?item wdt:P50 ?author . VALUES ?author { wd:Q43353 } .
# ?item wdt:P50 ?author . ?author wdt:P2348 ?p . VALUES ?p { wd:Q486761 wd:Q17167 wd:Q2277 }
OPTIONAL { ?item wdt:P136 ?genre }
OPTIONAL { ?item wdt:P571 ?date1 }
OPTIONAL { ?item wdt:P1191 ?date2 }
BIND(COALESCE (?date2, ?date1) as ?date )
BIND(IF(YEAR(?date)<1, CONCAT(str(1+YEAR(?date)*-1), " BC"), str(YEAR(?date))) as ?year )
OPTIONAL { ?item wdt:P1476 ?title }
SERVICE wikibase:label { bd:serviceParam wikibase:language "it,grc,la" }
}
ORDER BY ?date
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?author"):::projected
v7("?date"):::projected
v5("?date1")
v6("?date2")
v4("?genre")
v2("?item"):::projected
v8("?title"):::projected
v7("?year"):::projected
c7(["bd:serviceParam"]):::iri
c9(["it,grc,la"]):::literal
v2 --"wdt:P50"--> v4
bind0[/VALUES ?author/]
bind0-->v4
bind00(["wd:Q43353"])
bind00 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P136".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P571".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1191".-> v6
end
bind1[/"?date2?date1"/]
v6 --o bind1
v5 --o bind1
bind1 --as--o v7
bind2[/"if(year-from-dateTime(?date) < '1^^xsd:integer',concat(str('1^^xsd:integer' + year-from-dateTime(?date) * '-1^^xsd:integer'),' BC'),str(year-from-dateTime(?date)))"/]
v7 --o bind2
bind2 --as--o v7
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1476".-> v8
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end