Need SQL statement for the following case

Abdu_Allah
Abdu_Allah used Ask the Experts™
on
Hi, I have the following two tables: Categories(category_ID, Category_Name), Issues(Issue_ID,Issue_Name, Category_FK)

Each QUestion should belong to one categor.

I need SQL statement that select category_ID, Category_Name and number of issues in each category.

Thank you.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
try this

select t1.category_id, count(t2.issue_id)
from categories t1 inner join issues t2 on t1.category_id = t2.category_fk
group by t1.category_id
select t1.category_id, t1.category_name, count(t2.issue_id)
from categories t1 inner join issues t2 on t1.category_id = t2.category_fk
group by t1.category_id, t1.category_name

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial