Is it possible to group results and then filter by how many rows are in the group?
Something like this:
SELECT * FROM mytable WHERE COUNT(*) > 1 GROUP BY name
You want to use HAVING to filter on the aggregate function.
SELECT name, COUNT(*) FROM mytable GROUP BY name HAVING COUNT(*) > 1
You need to use HAVING
SELECT * FROM mytable GROUP BY name HAVING COUNT(*) > 1
Although, SELECT *
doesn't make much sense when you're grouping. I assume it's just for an example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With