query-3ce7a547d09022f387e00efd63a44dcc
Propertiesinstance of (P31)author (P50)subclass of (P279)language of work or name (P407)publication date (P577)title (P1476)genre (P136)
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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?work
(GROUP_CONCAT(DISTINCT ?title;SEPARATOR=" | ") AS ?titles)
?workLabel
?workDescription
(GROUP_CONCAT(DISTINCT ?classLabel;SEPARATOR=" | ") AS ?classes)
(GROUP_CONCAT(DISTINCT ?genreLabel;SEPARATOR=" | ") AS ?genres)
(GROUP_CONCAT(DISTINCT ?languageLabel;SEPARATOR=" | ") AS ?languagesOfWork)
?pubDate
WHERE {
VALUES ?author {
# wd:Q39829 #Stephen King
wd:Q36322 # Jane Austen
}
?work wdt:P31 ?class ;
wdt:P50 ?author .
FILTER NOT EXISTS {
VALUES ?exceptionClass {
wd:Q13406463
wd:Q3331189
wd:Q1279564
wd:Q17489659
}
?work wdt:P31/wdt:P279* ?exceptionClass .
}
FILTER NOT EXISTS {
?work wdt:P407/wdt:P279* wd:Q1860 .
}
OPTIONAL {
?work wdt:P577 ?pubDate .
BIND(YEAR(?pubDate) AS ?pubYear)
}
OPTIONAL {?work wdt:P1476 ?title}
OPTIONAL {?work wdt:P407 ?language}
OPTIONAL {?work wdt:P136 ?genre}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?work rdfs:label ?workLabel .
?work schema:description ?workDescription .
?class rdfs:label ?classLabel .
?language rdfs:label ?languageLabel .
?genre rdfs:label ?genreLabel .
}
}
GROUP BY ?work ?workLabel ?workDescription ?pubDate
ORDER BY ?pubYear
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?author")
v5("?class")
v12("?classLabel"):::projected
v16("?classes")
v3("?exceptionClass")
v9("?genre")
v14("?genreLabel"):::projected
v17("?genres")
v8("?language")
v13("?languageLabel"):::projected
v18("?languagesOfWork")
v6("?pubDate"):::projected
v7("?pubYear")
v7("?title"):::projected
v15("?titles")
v2("?work"):::projected
v11("?workDescription"):::projected
v10("?workLabel"):::projected
a2((" "))
a1((" "))
c10(["bd:serviceParam"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c3(["wd:Q1860"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P407"--> e0a1
e0a1 --"wdt:P279"--> e0c3
e0v1("?work"):::projected
e0a1((" ")):::projected
e0c3(["wd:Q1860"]):::iri
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> c1
f0 --> a1
f0 --> c2
f0 --> c3
v2 --"wdt:P407"--> a1
a1 --"wdt:P279"--> c3
f1[["not "]]
subgraph f1e1["Exists Clause"]
bind0[/VALUES ?exceptionClass/]
bind0-->e1v1
bind00(["wd:Q13406463"])
bind00 --> bind0
bind01(["wd:Q3331189"])
bind01 --> bind0
bind02(["wd:Q1279564"])
bind02 --> bind0
bind03(["wd:Q17489659"])
bind03 --> bind0
e1v2 --"wdt:P31"--> e1a1
e1a1 --"wdt:P279"--> e1v1
e1v1("?exceptionClass"):::projected
e1v2("?work"):::projected
e1a1((" ")):::projected
end
f1--EXISTS--> f1e1
f1 --> v2
f1 --> c4
f1 --> a2
f1 --> c2
f1 --> v3
bind2[/VALUES ?exceptionClass/]
bind2-->v3
bind20(["wd:Q13406463"])
bind20 --> bind2
bind21(["wd:Q3331189"])
bind21 --> bind2
bind22(["wd:Q1279564"])
bind22 --> bind2
bind23(["wd:Q17489659"])
bind23 --> bind2
v2 --"wdt:P31"--> a2
a2 --"wdt:P279"--> v3
bind3[/VALUES ?author/]
bind3-->v4
bind30(["wd:Q36322"])
bind30 --> bind3
v2 --"wdt:P31"--> v5
v2 --"wdt:P50"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P577".-> v6
bind4[/"year-from-dateTime(?pubDate)"/]
v6 --o bind4
bind4 --as--o v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1476".-> v7
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P407".-> v8
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P136".-> v9
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
v2 --"rdfs:label"--> v10
v2 --"schema:description"--> v11
v5 --"rdfs:label"--> v12
v8 --"rdfs:label"--> v13
v9 --"rdfs:label"--> v14
end
bind9[/"?title"/]
v7 --o bind9
bind9 --as--o v15
bind10[/"?classLabel"/]
v12 --o bind10
bind10 --as--o v16
bind11[/"?genreLabel"/]
v14 --o bind11
bind11 --as--o v17
bind12[/"?languageLabel"/]
v13 --o bind12
bind12 --as--o v18