How can I find the values in an SQL column that are repeated exactly N times? For example, let's say I have a column that has the values fanta, sprite, sprite, sprite, cola, cola, cola, and I want to find the values which is repeated exactly 3 times, which should return sprite and cola, but not fanta.
I tried to adapt the SQL from Find most frequent value in SQL column:
SELECT value1, COUNT(value1) AS value1_count
FROM table1
GROUP BY value1
WHERE value1_count=3
But that gives me near "WHERE": syntax error:, so obviously I'm not doing it right.
Aucun commentaire:
Enregistrer un commentaire