query: SELECT ?grouping (COUNT(DISTINCT ?entity) as ?count) (SAMPLE(?entity) as ?sample) WHERE { ?entity p:P31 []. {?entity wdt:P69 wd:Q309350.} UNION {?entity wdt:P69 wd:Q6806876. }. ?entity wdt:P21 ?grouping .} GROUP BY ?grouping HAVING (?count >= 1) ORDER BY DESC(?count) LIMIT 1000