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

Home -> Community -> Usenet -> comp.databases.theory -> Best way to do this query?

Best way to do this query?

From: Marshall <marshall.spight_at_gmail.com>
Date: 14 Jan 2007 12:10:51 -0800
Message-ID: <1168805451.817253.183270@m58g2000cwm.googlegroups.com>


I run in to this kind of query every so often. I wonder if there's a canonical best way to do it?

Consider the following schema:

Invoices:{invoiceid, customerid, date, amount}

Each invoice has an id, the id of the customer who opened the invoice, the date of the creation of the invoice, and the amount.

If I want to know the date of every customer's most recent invoice, that's easy:

select customerid, max(date) from Invoices group by customerid

But suppose I also want to know the id and amount of that particular invoice?

Marshall Received on Sun Jan 14 2007 - 14:10:51 CST

Original text of this message

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