query-87b57899a3d721dea6ea5659f21a97aa

rq turtle/ttl

TODO

Use at

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 ?person ?personLabel ?age
WHERE 
{
  {                                              # find events and winners
  ?event wdt:P31 wd:Q46190676 .                  # tennis event 
  ?event wdt:P361/wdt:P31/wdt:P361 wd:Q102113 .  # part of grans slam
  ?event wdt:P1346 ?person .                     # winner
  ?event wdt:P2094 wd:Q16893072 .                # competition class - mens singles
  }
UNION
  {                                              # find people who won stuff
  ?person wdt:2522 ?won .                        # we have a winner 
  ?won wdt:P361/wdt:P31/wdt:P361 wd:Q102113 .    # part of grans slam
  ?won wdt:P2094 wd:Q16893072 .                   # competition class - mens singles
  }
  ?person wdt:P569 ?birth .                      #dob
  MINUS { ?person wdt:P570 [] } .                #not dead
  BIND(YEAR(now())-YEAR(?birth) as ?age) .       #calculate age in years
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?age)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?age"):::projected v5("?birth") v2("?event") v3("?person"):::projected v4("?won") a5((" ")) a1((" ")) a2((" ")) a3((" ")) a4((" ")) c4(["wd:Q102113"]):::iri c12(["bd:serviceParam"]):::iri c2(["wd:Q46190676"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q16893072"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:2522"--> v4 v4 --"wdt:P361"--> a3 a3 --"wdt:P31"--> a4 a4 --"wdt:P361"--> c4 v4 --"wdt:P2094"--> c7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P31"--> c2 v2 --"wdt:P361"--> a1 a1 --"wdt:P31"--> a2 a2 --"wdt:P361"--> c4 v2 --"wdt:P1346"--> v3 v2 --"wdt:P2094"--> c7 end union0r <== or ==> union0l end v3 --"wdt:P569"--> v5 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P570"--> a5 end bind1[/"year-from-dateTime(NOW()) - year-from-dateTime(?birth)"/] v5 --o bind1 bind1 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end