query-a94076f332f9db27aff734307673333b

rq turtle/ttl

Propertiesinstance of (P31)facet of (P1269)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
select distinct  ?bucket (count(?country) as ?countryCount)
where {
  { 
    select ?country (count(?item) as ?folderCount)
    where {
      ?item wdt:P31 wd:Q91257459 ;
            wdt:P1269 ?country .
    }
    group by ?country
  }
  bind(if(?folderCount < 3, "01 - 2", 
          if(?folderCount < 11, "03 - 10", 
             if(?folderCount < 51, "11 - 50",
               if(?folderCount < 101, "51 - 100", "more than 100")))) as ?bucket)
}
group by ?bucket
order by ?bucket

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?bucket"):::projected v3("?country"):::projected v5("?countryCount") v4("?folderCount") v2("?item") c2(["wd:Q91257459"]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P1269"--> v3 bind1[/"count(?item)"/] v2 --o bind1 bind1 --as--o v4 bind2[/"if(?folderCount < '3^^xsd:integer','01 - 2',if(?folderCount < '11^^xsd:integer','03 - 10',if(?folderCount < '51^^xsd:integer','11 - 50',if(?folderCount < '101^^xsd:integer','51 - 100','more than 100'))))"/] v4 --o bind2 bind2 --as--o v5 bind4[/"count(?country)"/] v3 --o bind4 bind4 --as--o v5