Hi folks,
I am a recent dotnet and php programmer. I have been assigned to a project that involves inventory management. It is based on postgresql server as backend on windows platform.
My problem involves the following tables
a) Stock Issue (stock_issue) with columns Entryno, Date, Itemname, Qty
b) Stock Receipt (stock_receipt) with columns Entryno, Date, Itemname, Qty
Both tables have similar definations. A entry is made in stock_issue whenever items go out and vice-versa in stock receipt.
I have to generate a report with gives the sum of all issues and receipts , grouped itemwise. There is a extra fourth column with difference between the issue and receipt qty. Entryno and date are not required in the report.
I have already generated a report by using the following SQL statement.
Code:
SELECT issue_stock.itemname, SUM(DISTINCT issue_stock.qty) AS QtyOut, SUM(DISTINCT stock_receipt.qty) AS QtyIn
FROM issue_stock INNER JOIN
stock_receipt ON issue_stock.itemname = stock_receipt.itemname
GROUP BY issue_stock.itemname
the output is in the following format
Itemname QtyOut QtyIn
Item1 20 12
Item2 13 3
Item3 8 1
It is working ok.
My problem is only to add a fourth column that displays the difference between QtyOut and QtyIn
The related output must be as follows
Itemname QtyOut QtyIn Balance
Item1 20 12 8
Item2 13 3 10
Item3 8 1 7
Please suggest any solution, related to, how to add a Balance column
Thanx