Reputation: 5118
Need to write a MySQL query to check the database table and fetch distinct values and its count.
select distinct(fruits), count(distinct(fruits)) from table;
Will this suffice?
Upvotes: 0
Views: 67
Reputation: 14361
Why not use a group by
select fruits, count(fruits) as fc
from table
group by fruits
order by fc desc;
Upvotes: 3