I'm trying to create a basic rapport from these 2 tables:
Table Products
|--------|----------------|----------|
| PRO_Id | PRO_CategoryId | PRO_Name |
|--------|----------------|----------|
| 1 | 98 | Banana |
| 2 | 98 | Apple |
|--------|----------------|----------|
Table Categories
|--------|----------|
| CAT_Id | CAT_Name |
|--------|----------|
| 98 | Fruits |
| 99 | Other |
|--------|----------|
What I needed is this output:
|------------|
| Categories |
|------------|
| Fruits (2) |
|------------|
I would like a report listing all the categories from Categories but only when product from Products has a link (with is the case form Fruits but not for Other).
This is where I am actually:
SELECT CAT_Name, COUNT(PRO_Name IN sum)
FROM Categories
JOIN Products
ON Products.PRO_CategoryId = Categories.CAT_Id as sum
ORDER BY CAT_Name ASC
Anyone to help me with this please ?
Thanks.