Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: question using aggregate function

Re: question using aggregate function

From: Cimode <cimode_at_hotmail.com>
Date: Thu, 19 Jul 2007 01:23:17 -0700
Message-ID: <1184833397.418977.288290@z24g2000prh.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US