Re: question using aggregate function

From: Cimode <>
Date: Thu, 19 Jul 2007 01:23:17 -0700
Message-ID: <>

On Jul 17, 9:29 pm, Mia <> 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:
> -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 - 10:23:17 CEST

Original text of this message