comparing between two nested select statements [message #4421] |
Fri, 06 December 2002 14:47 |
Bryan Wyka
Messages: 4 Registered: December 2002
|
Junior Member |
|
|
I have a huge nested select statement. There is a piece that selects the sum from one table and subtracts it from another table. The problem comes to light when one of the table does not contain all of the same information that the other one does. Is there a way to make it link with out actually having the item exist. Below is the statement and some other notes.
select sku.item as item1
,(sku.oh - nvl(cu.qty,0)) as qty
from (
select sk.item, sum(sk.oh) oh from sku sk, loc
where sk.loc = loc.loc and
loc.descr2 = 'CONSUMER' and
sk.item = '080.0006586.003'
group by sk.item
)sku,
item i,
(/*this is the part that does not contain the above information*/
select cu.item, sum(cu.qty) qty from custorder cu, loc
where cu.loc = loc.loc and
loc.descr2 = 'CONSUMER' and
cu.item = '080.0006586.003'
group by cu.item
) cu
where sku.item =i.item and
sku.item = cu.item
if either of these nested statement are null then the entire statement fails.
Help please.
|
|
|
|