create table categories (
id integer primary key,
parent integer references categories,
name varchar(50) not null
);
create table manufacturers (
id integer primary key,
name varchar(30) not null
);
create table goods (
id integer primary key,
category integer references categories,
manufacturer integer references manufacturers,
name varchar(50) not null
);
select
m.name,
count(*) as goods_count
from goods as g
inner join manufacturers as m
on g.manufacturer = m.id
where category = 1
group by m.name;
Живой пример в sqlfiddle