glitter
glitter copied to clipboard
What about WITH
E.g.
Fictional characters whose birth/death date is in the current decade
SELECT DISTINCT ?character ?characterLabel ?birth ?death WITH {
# Fictional character subclasses as a named subquery
SELECT ?fictiontype WHERE {
?fictiontype wdt:P279* wd:Q95074. hint:Prior hint:gearing "forward".
}
} AS %i
WHERE
{
INCLUDE %i
?character wdt:P31 ?fictiontype.
# Date of birth
{ ?character wdt:P569 ?birth . }
# Date of death
UNION { ?character wdt:P570 ?death . }
# Get actual decade to compare with dates
BIND(xsd:integer(YEAR(NOW())/10) as ?actual_decade).
# Only show characters born or deceased in the current decade
FILTER(xsd:integer(YEAR(?birth)/10) = ?actual_decade || xsd:integer(YEAR(?death)/10) = ?actual_decade)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
}
} ORDER BY ?birth ?death
related to complex queries / subqueries in my opinion, so I'd drop it for now?
maybe add these considerations to the new vignette about complex queries ?