query: SELECT ?grouping (COUNT(DISTINCT ?entity) as ?count) (SAMPLE(?entity) as ?sample) WHERE { ?entity wdt:P166/wdt:P361 wd:Q163700. ?entity wdt:P166 ?grouping .} GROUP BY ?grouping HAVING (?count < 1000) ORDER BY DESC(?count) LIMIT 1000