query-0a531e089913ee279366c88d1f61a788
10:49, 7 November 2019 (UTC)) talk (SteakThe limit is of course just for testing purposes. Problem is, that the MIN does not choose the smalles value for a given item, but returns all substraction results. Therefore the query would time out without limit. Can somebody help?
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?age_at_first_elo WHERE {
{
SELECT ?item (MIN(?elo_time) AS ?min_time) WHERE {
?item p:P1087/pq:P585 ?elo_time .
} GROUP BY ?item
}.
?item wdt:P569 ?dob .
BIND(xsd:integer(YEAR(?min_time) - YEAR(?dob)) AS ?age_at_first_elo) .
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY ASC(?age_at_first_elo)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?age_at_first_elo"):::projected
v5("?dob")
v3("?elo_time")
v2("?item"):::projected
v4("?min_time")
a1((" "))
c5(["bd:serviceParam"]):::iri
c7(["en"]):::literal
v2 --"p:P1087"--> a1
a1 --"p:qualifier/P585"--> v3
bind1[/"min(?elo_time)"/]
v3 --o bind1
bind1 --as--o v4
v2 --"p:direct/P569"--> v5
bind2[/"http://www.w3.org/2001/XMLSchema#integer(year-from-dateTime(?min_time) - year-from-dateTime(?dob))"/]
v4 --o bind2
v5 --o bind2
bind2 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end