Reputation: 3033
I have table like this:
id ownerid title
1 1 a
2 1 b
3 2 c
4 3 d
5 3 e
5 3 f
Now i want to find count of maximum records of ownerid. means in above example, there is 2 records for ownerid 1, 1 record for ownerid 2 and 3 records for ownerid 3. So output should be 3
.
So how to do that?
SQL :
SELECT count(ownerid) FROM `tblowner` group by ownerid
Upvotes: 1
Views: 86
Reputation: 44874
You can use order by
SELECT count(ownerid) as tot
FROM `tblowner`
group by ownerid
order by tot desc limit 1;
Upvotes: 2