У меня есть три таблицы
Основные записи товара: основные данные магазинов
id integer NOT NULL DEFAULT, primary key
name character varying(255),
description character(255),
price double precision,
tax double precision,
readytosales character(1) DEFAULT 'N'::bpchar,
itemgroupid integer,
uom character varying(30),
quantity double precision DEFAULT 0,
Покупка: подробности покупки магазинов
purchaseid integer NOT NULL DEFAULT,
quantity double precision DEFAULT 0,
purchasemasterid integer NOT NULL,
itemid integer NOT NULL,
itemprice double precision DEFAULT 0.00,
Продажи: подробности продаж магазинов
salesid integer NOT NULL DEFAULT,
quantity double precision DEFAULT 0,
salesmasterid integer NOT NULL,
itemid integer,
itemprice double
формула, используемая для получения сводной информации об акциях:
itemmaster.quantity + purchase.quantity -sales.quantity
Я использовал следующий запрос для получения подробной информации, но не смог получить результаты
select im.id as itemid,
name as itemname,
im.quantity as oepningquantity,
im.price as openingprice,
(im.quantity * im.price) as openingbalance,
p.quantity as purchasequantity, p.itemprice as purchaseprice,
(p.quantity * p.itemprice)as totalpurchaseprice,
s.quantity as salesquanity, s.itemprice as saleprice,
(s.quantity *s.itemprice)as totalsalesprice
from item_master as im
full outer join purchase as p on im.id=p.itemid
full outer join sales as s on im.id=s.itemid