I have two tables namely: listings and tags. These are sample records:
Listings Table
Tags Table
This is my sample SQL query:
SELECT l.tag,
count(case when l.type = 'Consumer' then l.type = '' end) as consumer,
count(case when l.type = 'Supplier' then l.type = '' end) as supplier
FROM listings AS l
LEFT JOIN tags AS t
ON l.tag = t.tag
GROUP BY t.tag, l.type
Any ideas how to do it? I would gladly appreciate any kind of help. Thank you.
UPDATED: Changed to:
SELECT l.tag,
count(case when l.type = 'Consumer' then l.type = '' end) as consumer,
count(case when l.type = 'Supplier' then l.type = '' end) as supplier
FROM listings AS l
LEFT JOIN tags AS t
ON l.tag = t.tag
GROUP BY t.tag, l.type
OUTER keyword seems working however I need to display still the AZ with 0 and 0 for Consumer and Supplier.