count of max in mysql example query

Count:
Count is an aggregate function which returns the count of rows with respect to our query conditions.

Max:
Max is an aggregate function which returns the max of rows value of a particular column with respect to our query condition. For string which returns the maximum length value instead of occurences.

So you have to use count of max to get the more occurences of the same string in the mysql.

Query:
[sql]
select searchkey,count(searchkey) as val from search where name=’Hems’ group by searchkey order by val desc limit 1
[/sql]

Leave a Reply