query: #  Query to find the most common values for the property ?prop
   #  on items in the class ?class
   #  when ?class = Q5 and ?prop = P27
   #  Query generated by [[Template:TopList]]
  
  SELECT ?value ?valueLabel ?count WHERE {
    {
      SELECT ?value (COUNT(DISTINCT ?a) AS ?count) WHERE {
         ?a ?prop ?value . 
         ?a wdt:P31 ?class .
         BIND (wdt:P27 AS ?prop) .
         BIND (wd:Q5 AS ?class) .
      } GROUP BY ?value
    } . 
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "en" .
    }
  }
  # HAVING (?count > 1)        ### use this to show only repeated values
  ORDER BY DESC(?count) ?valueLabel
  LIMIT 10