frosty frosty - 6 months ago 36
MySQL Question

Selecting rows from database only when those rows exceeds a certain number

I need to select specific rows from the database, but only if those rows exceeds a certain number. For instance, I need to get a specific name from the database, but only if that name has more than 25 rows. How would I write that query in SQL?

SELECT name FROM names WHERE count(name) >= 25

Answer
SELECT name 
  FROM names
GROUP BY name
 HAVING count(name) >= 25;