query-fc1d4121c6e072c4deb7a5db7c2f9a2d
Get items where "instance of" is a subclass of another item: (Q95074)fictional character (P279)subclass of is a (P31)instance of I am working on this query to get the items where
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 DISTINCT ?character ?characterLabel ?birth ?death
WHERE {
{
SELECT DISTINCT ?fictiontype
WHERE {
# fictional character subclasses
?fictiontype wdt:P279 wd:Q95074.
}
}
?character wdt:P31 ?fictiontype.
OPTIONAL { ?character wdt:P570 ?death .}
OPTIONAL { ?character wdt:P569 ?birth }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?birth"):::projected
v2("?character"):::projected
v3("?death"):::projected
v1("?fictiontype")
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c2(["wd:Q95074"]):::iri
v1 --"wdt:P279"--> c2
v2 --"wdt:P31"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P570".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P569".-> v4
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end