I want to do something like this:
SELECT *
FROM db.table
WHERE COUNT(someField) > 1
How can I achieve this in MySql?
I want to do something like this:
SELECT *
FROM db.table
WHERE COUNT(someField) > 1
How can I achieve this in MySql?
Here you go:
SELECT Field1, COUNT(Field1)
FROM Table1
GROUP BY Field1
HAVING COUNT(Field1) > 1
ORDER BY Field1 desc
SELECT username, numb from(
Select username, count(username) as numb from customers GROUP BY username ) as my_table
WHERE numb > 3
Without HAVING
SELECT COL,TOTAL
FROM (SELECT SPORT, COUNT(COL) AS TOTAL FROM db.table GROUP BY SPORT)
WHERE TOTAL > 100 ORDER BY TOTAL
or with HAVING
SELECT COL, COUNT(COL) AS TOTAL
FROM db.table
GROUP BY SPORT HAVING TOTAL > 100
ORDER BY COL
Maybe:
SELECT *
FROM [Table]
where field IN (
select field
from [Table]
group by field
having COUNT(field)>1 )