query-ad025a0f3f1c048c5a292828027d012c

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel WHERE {

                                           #some means of cutting down the number of items considered
  {
   ?item wdt:P31 wd:Q55488.
   ?item wdt:P17 wd:Q142. 
  }


  ?item p:P18 ?stat .                        # has an image
  ?stat wikibase:rank wikibase:NormalRank .  # normal rank

  ?item p:P18 ?stat2 . 
  ?stat2 wikibase:rank wikibase:NormalRank . 

  filter(str(?stat) > str(?stat2) )          # image statements are different
                                             # no P18s of other ranks
  filter not exists {?item p:P18/wikibase:rank wikibase:PreferredRank . }
  filter not exists {?item p:P18/wikibase:rank wikibase:DeprecatedRank . }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v2("?stat") v3("?stat2") a2((" ")) a1((" ")) c4(["wikibase:PreferredRank"]):::iri c3(["wikibase:DeprecatedRank"]):::iri c9(["wikibase:NormalRank"]):::iri c13(["en"]):::literal c11(["bd:serviceParam"]):::iri c6(["wd:Q55488"]):::iri c8(["wd:Q142"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:P18"--> e0a1 e0a1 --"wikibase:rank"--> e0c3 e0v1("?item"):::projected e0a1((" ")):::projected e0c3(["wikibase:DeprecatedRank"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> a1 f0 --> c2 f0 --> c3 v1 --"p:P18"--> a1 a1 --"wikibase:rank"--> c3 f1[["not "]] subgraph f1e1["Exists Clause"] e1v1 --"p:P18"--> e1a1 e1a1 --"wikibase:rank"--> e1c3 e1v1("?item"):::projected e1a1((" ")):::projected e1c3(["wikibase:PreferredRank"]):::iri end f1--EXISTS--> f1e1 f1 --> v1 f1 --> c1 f1 --> a2 f1 --> c2 f1 --> c4 v1 --"p:P18"--> a2 a2 --"wikibase:rank"--> c4 f2[["str(?stat) > str(?stat2)"]] f2 --> v2 f2 --> v3 v1 --"p:direct/P31"--> c6 v1 --"p:direct/P17"--> c8 v1 --"p:P18"--> v2 v2 --"wikibase:rank"--> c9 v1 --"p:P18"--> v3 v3 --"wikibase:rank"--> c9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end