query-d329f36cac0251816eb32bc541b335d3

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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
  SERVICE bd:slice {
    ?item wdt:P18 [].
    bd:serviceParam bd:slice.offset 0 . # Start at item number (not to be confused with QID)
    bd:serviceParam bd:slice.limit 10000 . # List this many items
    }


  ?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") a3((" ")) a2((" ")) a1((" ")) c4(["wikibase:PreferredRank"]):::iri c3(["wikibase:DeprecatedRank"]):::iri c12(["wikibase:NormalRank"]):::iri c15(["en"]):::literal c9(["0^^xsd:integer"]):::literal c7(["bd:serviceParam"]):::iri c11(["10000^^xsd:integer"]):::literal 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 subgraph s1["http://www.bigdata.com/rdf#slice"] style s1 stroke-width:4px; v1 --"p:direct/P18"--> a3 c7 --"bd:slice.offset"--> c9 c7 --"bd:slice.limit"--> c11 end v1 --"p:P18"--> v2 v2 --"wikibase:rank"--> c12 v1 --"p:P18"--> v3 v3 --"wikibase:rank"--> c12 subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c7 --"wikibase:language"--> c15 end