query-3f2a9261c26013747380c7b1e735cc0b

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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?player ?playerLabel ?dob ?goal_date ?goal_age_days ?goal_age_years
WHERE
{
  {
    SELECT ?player ?dob (?date_first AS ?goal_date) (?age_first AS ?goal_age_days)
    {

{
  SELECT ?player ?dob ?date_first ?date_latest ?age_first ?age_latest
  WHERE
  {
    ?player p:P6509 ?p6509stm . # goals
    ?p6509stm pq:P7124 ?date_first .
    ?p6509stm pq:P7125 ?date_latest .
    ?p6509stm pq:P642 wd:Q484028 . # for UEFA Super Cup
    ?player wdt:P569 ?dob . # Date of birth
    BIND(?date_first - ?dob AS ?age_first)
    BIND(?date_latest - ?dob AS ?age_latest)
  }
}    }
    ORDER BY ASC(?goal_age_days)
    LIMIT 10
  }
  UNION
  {
    SELECT ?player ?dob (?date_latest AS ?goal_date) (?age_latest AS ?goal_age_days)
    {

{
  SELECT ?player ?dob ?date_first ?date_latest ?age_first ?age_latest
  WHERE
  {
    ?player p:P6509 ?p6509stm . # goals
    ?p6509stm pq:P7124 ?date_first .
    ?p6509stm pq:P7125 ?date_latest .
    ?p6509stm pq:P642 wd:Q484028 . # for UEFA Super Cup
    ?player wdt:P569 ?dob . # Date of birth
    BIND(?date_first - ?dob AS ?age_first)
    BIND(?date_latest - ?dob AS ?age_latest)
  }
}    }
    ORDER BY DESC(?goal_age_days)
    LIMIT 10
  }
  BIND(?goal_age_days/365.25 AS ?goal_age_years)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ASC(?goal_age_days)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?age_first") v10("?age_latest") v4("?date_first") v5("?date_latest") v6("?dob"):::projected v10("?goal_age_days"):::projected v10("?goal_age_years"):::projected v10("?goal_date"):::projected v3("?p6509stm") v2("?player"):::projected c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c5(["wd:Q484028"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"p:P6509"--> v3 v3 --"p:qualifier/P7124"--> v4 v3 --"p:qualifier/P7125"--> v5 v3 --"p:qualifier/P642"--> c5 v2 --"p:direct/P569"--> v6 bind0[/"?date_first - ?dob"/] v4 --o bind0 v6 --o bind0 bind0 --as--o v10 bind1[/"?date_latest - ?dob"/] v5 --o bind1 v6 --o bind1 bind1 --as--o v10 bind2[/"?date_latest"/] v5 --o bind2 bind2 --as--o v10 bind3[/"?age_latest"/] v10 --o bind3 bind3 --as--o v10 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:P6509"--> v3 v3 --"p:qualifier/P7124"--> v4 v3 --"p:qualifier/P7125"--> v5 v3 --"p:qualifier/P642"--> c5 v2 --"p:direct/P569"--> v6 bind4[/"?date_first - ?dob"/] v4 --o bind4 v6 --o bind4 bind4 --as--o v10 bind5[/"?date_latest - ?dob"/] v5 --o bind5 v6 --o bind5 bind5 --as--o v10 bind6[/"?date_first"/] v4 --o bind6 bind6 --as--o v10 bind7[/"?age_first"/] v10 --o bind7 bind7 --as--o v10 end union0r <== or ==> union0l end bind8[/"?goal_age_days / '365.25^^xsd:decimal'"/] v10 --o bind8 bind8 --as--o v10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end