| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Best way to do this query?
Carlos M. Calvelo schreef:
>
> select inv.invoiceid, inv.customerid, inv.amount, max(inv.date)
> from Invoices as inv
> group by inv.invoiceid, inv.customerid, inv.amount
> having max(inv.date) = (select max(date) from Invoices where customerid
> = inv.customerid)
> order by inv.customerid
>
oops... there is no need to aggregate. it's same as:
select inv.invoiceid, inv.customerid, inv.amount, inv.date
from Invoices as inv
where inv.date = (select max(date) from Invoices where customerid =
inv.customerid)
order by inv.customerid
Carlos Received on Wed Jan 17 2007 - 10:26:18 CST
![]() |
![]() |