select last time for ordering - complex sql

From: jodleren <sonnich_at_hot.ee>
Date: Tue, 27 Apr 2010 08:49:56 -0700 (PDT)
Message-ID: <f36887db-510d-4020-b092-05643dcd0502_at_s9g2000yqa.googlegroups.com>



Hi all

Basically I have this, which gives me a tree of the product and subasseblies.

SELECT level, stuff from products
CONNECT BY PRIOR products.subpart = products.product START WITH products = 'productname'

Now, they want to know delevery times for the last time when the parts were ordered, this goes like:

select ordertable.orderdata, delirverytable.deliverydate from ordertable, delirverytable
where ordertable.orderno = delirverytable.orderno and delirverytable.product='Something'
and delivery date in (select max(delirverytable2.deliverydate) from delirverytable2 where
delirverytable2.product = delirverytable.product)

basically - I get the latest date for delivery (if present) in order to get one row only.

Now, can I mix all this together?
The point is, that some parts might never have been ordered, so they are not in - at least one of - the order and delivery tables.

WBR
Sonncih Received on Tue Apr 27 2010 - 10:49:56 CDT

Original text of this message