getting distinct column name and count when based on another table <p>i have the following query:</p> <pre><code>select cc.category from companies c left join categories cc on c.category_id = cc.category_id where company_title like '%gge%'; </code></pre> <p>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:</p> <p>CATEGORY NAME | XXX ( where XXX is the count )</p> <p>anyone can help?</p>