Sobes.tech
Middle+

How to select all cities from a table that are repeated more than 10 times?

sobes.tech AI

Answer from AI

To select all cities from a table that occur more than 10 times, you can use an SQL query with grouping and filtering by record count:

SELECT city, COUNT(*) AS city_count
FROM table_name
GROUP BY city
HAVING COUNT(*) > 10;

Explanation:

  • GROUP BY city groups rows by city name.
  • COUNT(*) counts the number of records in each group.
  • HAVING COUNT(*) > 10 filters groups where the record count is greater than 10.

As a result, you will get a list of cities with their occurrence counts exceeding 10.