
August 19th, 2004, 02:59 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
calculating difference - help, please?
hello,
i am having problems with sql. suppose that i have two tables. tblOrders and tblServed. in order to find the exact match, both of their OrderID and ItemNo should match with the other table. To know how many items are not yet served, their difference should be calculated (tblOrders.Qty - tblServed.Qty) in the query. i always get a NULL value even though both fields have the same data types and no zero values are found in their databases.
SELECT DISTINCT TOP 100 PERCENT tblOrders.<fields>,
(SELECT tblOrders.Qty - tblServed.Qty FROM tblOrders, tblServed
WHERE tblOrders.OrderID = tblServed.OrderID AND tblOrders.ItemNo = tblServed.ItemNo) AS UnservedQty
FROM tblServed RIGHT OUTER JOIN tblOrders ON tblOrders.OrderID = tblServed.OrderID AND tblOrders.ItemNo = tblServed.ItemNo
if there were any related solutions, problems like this posted before, please let me know.
|