current_date>current_date-'1 day'::interval
table products (id serial, category_id small int, name text, vendor text)
table property(id serial,name text, value)
table product_property(product_id big int, property_id big int)
select g.id, g.name, g.description, g.bar_code, s.count as total_sales, r.count as total_receipts, r.count-s.count as total from good g join (select good_id, count(*) from receipt group by good_id) r on g.id = r.good_id
join (select good_id, count(*) from sale group by good_id) s on g.id = s.good_id
select house_id
into l_house_id
from houses_all
where COALESCE(houses_all.corp,'somevalue') = COALESCE(l_corp,'somevalue')