1

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 
DS9
  • 2,995
  • 4
  • 52
  • 102

1 Answers1

2

You can use order by

SELECT count(ownerid) as tot 
FROM `tblowner` 
group by ownerid 
order by tot desc limit 1;
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63