hat you need is to filter on the count of the number of races for each horse. The HAVING clause does exactly what we need here – it has syntax like the WHERE clause, but it is applied to each group after grouping has taken place
Main diff between HAVING and WHERE
-
- WHERE is applied before grouping, it is usually used to narrow the SELECT statement's output
-
- HAVING is applied after grouping. It is usually used when grouping is needed to incorporate function generated values into a new table requested by the query