| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Best way to do this query?
Cimode wrote:
> JOG wrote:
>
> > SELECT A.invoiceid, A.customerid, A.date, A.amount, Max(A.date -
> > B.date)
> > FROM invoices AS A
> > INNER JOIN invoices AS B
> > ON A.customerid = B.customerid
> > GROUP BY A.customerid
> I do not see how this query could produce the desired result
It concatanates each invoice_id for a particular customer with every other invoice they have created, then calculates the most recent invoice by comparing the time differentials for each generated tuple. Ugly as sin, but it works, despite leaving you with an extraneous Max(A.date = B.date) column that essentially organizes the whole horrific fudge. Received on Wed Jan 17 2007 - 11:12:43 CST
![]() |
![]() |