Reputation: 17104
i have the following query:
select cc.category from companies c
left join categories cc on c.category_id = cc.category_id
where company_title like '%gge%';
which return categories with duplicate rows. what i need is to get distinct categories, with the total count of accurences of that category, something like:
CATEGORY NAME | XXX ( where XXX is the count )
anyone can help?
Upvotes: 0
Views: 333
Reputation: 8629
Use this query instead :-
select distinct cc.category,
count(cc.category) as totalCategoryCount
from companies c
left join categories cc on c.category_id = cc.category_id
where company_title like '%gge%'
group by cc.category
Upvotes: 0