query-f82676d6afcbbfda28b256654753629b

rq turtle/ttl

19:08, 6 March 2020 (UTC)) talk (AyackThanks. 19:27, 6 March 2020 (UTC)) talk (AyackBy doing that, I no longer have an error, but I've only the result of the first part of the UNION... 19:12, 6 March 2020 (UTC) JuraYou need to change "(SUM(?count) AS ?count)" to something like (SUM(?count) AS ?count1) ---

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?type ?typeLabel (SUM(?count) as ?count_types) 
{
    {  SELECT ?instance (COUNT(DISTINCT ?item) as ?count)
       WHERE
       {
          ?item  wdt:P17 wd:Q142. 
          ?item (wdt:P31/wdt:P279*) wd:Q16970 ; wdt:P31 ?instance
       }
       GROUP BY ?instance
    }             
    BIND( If(?count < 51 , wd:Q55107540 , ?instance) as ?type) 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,en". }
}
GROUP BY ?type ?typeLabel 
ORDER BY (?type = wd:Q55107540 ) DESC(?count_types)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?count"):::projected v6("?count_types") v4("?instance") v3("?item") v6("?type"):::projected a1((" ")) c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,fr,en"]):::literal c6(["wd:Q16970"]):::iri c3(["wd:Q142"]):::iri v3 --"wdt:P17"--> c3 v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c6 v3 --"wdt:P31"--> v4 bind1[/"count(?item)"/] v3 --o bind1 bind1 --as--o v5 bind2[/"if(?count < '51^^xsd:integer','wd:Q55107540',?instance)"/] v5 --o bind2 v4 --o bind2 bind2 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind4[/"sum(?count)"/] v5 --o bind4 bind4 --as--o v6