First, regarding the stored procedure recommendation, it depends on what
you are trying to do. The decision to go with a stored procedure vs a view
depends on how this fits into the rest of your application.
Here is what I would do for the SQL though:
WITH base_agg AS (
select part_no,
On 9/23/2013 10:13 PM, Bret Stern wrote:
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(shi