title: PostgreSQL select query doesn't work
body: <p>I have 3 tables:</p>
  
  <pre><code>CREATE table materials
   (id serial primary key not null,
   name varchar(50) not null,
   unit varchar(10) not null default 'шт',
   price decimal(12, 2) not null check (price&gt;0));
  
  CREATE table warehouses 
  (id serial primary key not null,
   lastname varchar(25) not null);
  
  CREATE table materials_in_warehouses
   (id_warehouses integer references warehouses(id) on update cascade on delete cascade,
   id_materials integer references materials(id),
   unit varchar(15) default 'шт',
   count integer not null CHECK (count&gt;0),
   lastdate date not null, 
  primary key (id_warehouses, id_materials);
  </code></pre>
  
  <p>And i need to select for each material : name; count of warehouses, where the material is present in an amount of > 100.</p>
  
  <p>I tried to do something like this:</p>
  
  <pre><code>select materials.name, count(select * from materials_in_warehouses where 
  materials.id = materials_in_warehouses.id_materials AND material_in_warehouses.count &gt; 100) as sount from  materials;
  </code></pre>
  
  <p>But of course, this nonsense can't work.</p>
  
  <p>Thank you in advance.</p>