SQL filter only if each unique value has more than N records Here is my sample SQL statement:

SELECT DAY,
       name,
       value
FROM my_table
WHERE DAY = '${date}'
GROUP BY DAY
         name,
         value
ORDER BY name ASC


For example, 3 unique names in 'name' column: Alice, Bob, Clark.

Alice has 5 rows, Bob has 9 rows, Clark has 12 rows.

I want to add a filter if rows with same value > 10 rows. 'Clark' satisfies in this case.

How to add this? under WHERE?
Welcome.

Here is what you want. But please follow the notes given below too.

SELECT day,
       ip_address,
       user_name,
       timestamp,
       count(ip_address) AS tct
FROM my_table
WHERE day = current_date()
GROUP BY ip_address
HAVING tct&gt; 10
ORDER BY ip_address ASC



Do not use select * instead give specific column names.
You are speaking of count per name in your question but your code groups by DAY, name, value - check if it is fine for you.
It is better (always) to list your data structure and the output needed along with your code to get best answer.