query-cf61325213e1a0ee03410343b89e13f6

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) --- )?count_types(DESC ) Q55107540:wd = ?type( ORDER BY ?typeLabel ?type GROUP BY } } ."[AUTO_LANGUAGE],fr,en" language:wikibase serviceParam:bd { label:wikibase SERVICE )?type as )?instance , Q55107540:wd , 51 < ?count(If (BIND } ?instance GROUP BY } ?instance P31:wdt ; Q16970:wd )*P279:wdt/P31:wdt( ?item .Q142:wd P17:wdt ?item { WHERE )?count as )?item DISTINCT(COUNT( ?instance SELECT { { )?count_types as )?count(SUM( ?typeLabel ?type SELECT 19:41, 6 March 2020 (UTC) JuraThere seems to be another issue with the aggregate. I re-wrote it slightly differently above. I suppose that's what you are looking for. ---

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 ?instance ?instanceLabel (COALESCE(?instanceLabel, " autres") AS ?itemLabel) ?count {{
    SELECT ?instance (COUNT(DISTINCT ?item) as ?count) {
          ?item  wdt:P17 wd:Q142. 
          ?item (wdt:P31/wdt:P279*) wd:Q16970 ; wdt:P31 ?instance.}
    GROUP BY ?instance
    HAVING (?count > 50)}
  UNION {
    SELECT (SUM(?count0) AS ?count) {{
        SELECT ?instance (COUNT(DISTINCT ?item) as ?count0) {
          ?item wdt:P17 wd:Q142. 
          ?item (wdt:P31/wdt:P279*) wd:Q16970 ; wdt:P31 ?instance.}
        GROUP BY ?instance
        HAVING (?count0 <=50)}}}
 SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }}
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?count"):::projected v5("?count0") v3("?instance"):::projected v2("?item") v5("?itemLabel") a1((" ")) a2((" ")) c8(["bd:serviceParam"]):::iri c6(["wd:Q16970"]):::iri c10(["fr"]):::literal c3(["wd:Q142"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["?count0 <= '50^^xsd:integer'"]] f0 --> v5 v2 --"wdt:P17"--> c3 v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c6 v2 --"wdt:P31"--> v3 bind2[/"count(?item)"/] v2 --o bind2 bind2 --as--o v5 bind4[/"sum(?count0)"/] v5 --o bind4 bind4 --as--o v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f5[["?count > '50^^xsd:integer'"]] f5 --> v5 v2 --"wdt:P17"--> c3 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c6 v2 --"wdt:P31"--> v3 bind7[/"count(?item)"/] v2 --o bind7 bind7 --as--o v5 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind8[/"?instanceLabel' autres'"/] null --o bind8 bind8 --as--o v5