SP to calc shipments vs receipts

From: Bret Stern <bret_stern(at)machinemanagement(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: SP to calc shipments vs receipts
Date: 2013-09-24 05:13:09
Message-ID: 1379999589.7123.9.camel@centos-dev.machinemanagement.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have an inventory transaction table with several fields,
specifically:
part_no
trans_type
trans_qty

part_no | trans_type | trans_qty
abc REC 5000 (receipt)
abc REC 400 (receipt)
abc SHP 1000 (shipment)
abc ALL 1000 (allocated)

Looking for the best way to show following totals with SQL

on_hand | allocated | available
3400 1000 4400

Thinking of writing a stored procedure that has the aggregate queries,
and returns the values defined above for this example.

Is this a recommended way?

B Stern

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2013-09-24 06:01:38 Re: SP to calc shipments vs receipts
Previous Message Karl Denninger 2013-09-24 02:45:51 Re: streaming replication not working