Subject | SQL Help |
---|---|
Author | Robert martin |
Post date | 2007-10-16T23:12:23Z |
Hi
We have a table called StockLevel that had 1 record per item, per area
(Region). We have expanded this so that an item can have multiple
entries for a given region. However I am struggling to come to grips
with how to rewrite a large number of SQLs that have used this table.
An example might be
Select Tablea.x, Tablea.y, Tableb.z, StockLevel.ShelfQty
From Tablea
JOIN Tableb on .....
JOIN StockLevel ON (StockLevel.ItemRef = :ItemRef AND
StockLevel.RegionRef = :RegionRef)
These have all worked fine, however now we want the SUM of ShelfQty for
the specified region. Is it possible to re write the SQL above to do this?
I have written a Stored procedure to return the Sumed quantities for a
given itemref, regionref combination. But I am not sure it helps for
examples like the aboe.
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
We have a table called StockLevel that had 1 record per item, per area
(Region). We have expanded this so that an item can have multiple
entries for a given region. However I am struggling to come to grips
with how to rewrite a large number of SQLs that have used this table.
An example might be
Select Tablea.x, Tablea.y, Tableb.z, StockLevel.ShelfQty
From Tablea
JOIN Tableb on .....
JOIN StockLevel ON (StockLevel.ItemRef = :ItemRef AND
StockLevel.RegionRef = :RegionRef)
These have all worked fine, however now we want the SUM of ShelfQty for
the specified region. Is it possible to re write the SQL above to do this?
I have written a Stored procedure to return the Sumed quantities for a
given itemref, regionref combination. But I am not sure it helps for
examples like the aboe.
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd