| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: question using aggregate function
On Jul 17, 9:29 pm, Mia <nos..._at_cox.net> wrote:
Snipped...
> But I'm trying to
> write a query that would return only the supplier_id of the most
> recently placed order. How would I do that? I thought maybe:
[Snipped]
> -Mia
O1 the set of all orders (ALL elements)
O2 the set including the most recent date of order (1 element)
A simple intersect between O1 and O2 through the most recent date will allow to produce the desired result...Expressed in SQL
select O1.supplier_id from orders O1 inner join --> SET R1
( select max(order_date) highest_date from orders --> SET R2 ) O2 on O1.order_date = O2.highest_date
Hope this helps... Received on Thu Jul 19 2007 - 03:23:17 CDT
![]() |
![]() |