You might be better off with something more like this:
SELECT COUNT(P.*) AS p_count, P.p_product_category_id FROM p_product P
WHERE P.p_product_category_id IN (SELECT DISTINCT id FROM
p_product_category) GROUP BY P.p_product_category_id;
obviously tailored to YOUR schema... not mine...
--
Greg P
# product table (simplified):
create table p (
id char(22) not null primary key,
name text,
desc text
);
# product category table (simpl.):
create table pc (
id char(22) not null primary key,
name text,
desc text
);
# table that maps products into categories:
create table p_pc (
id ch