query-d4be2b3450f1c4e110ceff82f381984a

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 ?item ?itemLabel ?date_old ?rank ?stat where
{
   { SELECT ?item where
{
   {
SELECT ?item (max(?date_) as ?date) 
WHERE 
{
  ?item wdt:P31 wd:Q747074.
  ?item p:P1082 ?stat.
  ?stat pq:P585 ?date_.
  } group by ?item }  ?item p:P1082 ?stat.
  ?stat pq:P585 ?date.
  filter not exists {    ?stat a wikibase:BestRank. }
  ?stat wikibase:rank ?rank.      
}  }  ?item p:P1082 ?stat.
  ?stat pq:P585 ?date_old.
  ?stat a wikibase:BestRank. 
  ?stat wikibase:rank ?rank.      
  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("?date") v3("?date_") v6("?date_old"):::projected v2("?item"):::projected v5("?rank"):::projected v1("?stat"):::projected c9(["bd:serviceParam"]):::iri c2(["wikibase:BestRank"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c4(["wd:Q747074"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"a"--> e0c2 e0v1("?stat"):::projected e0c2(["wikibase:BestRank"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> c2 v1 --"a"--> c2 v2 --"p:direct/P31"--> c4 v2 --"p:P1082"--> v1 v1 --"p:qualifier/P585"--> v3 bind2[/"max(?date_)"/] v3 --o bind2 bind2 --as--o v4 v2 --"p:P1082"--> v1 v1 --"p:qualifier/P585"--> v4 v1 --"wikibase:rank"--> v5 v2 --"p:P1082"--> v1 v1 --"p:qualifier/P585"--> v6 v1 --"a"--> c2 v1 --"wikibase:rank"--> v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end