query-cf61325213e1a0ee03410343b89e13f6
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
- https://query.wikidata.org/sparql
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)