MySQL Forums
Forum List  »  Newbie

Problem with GROUP BY
Posted by: Stephen Bennett
Date: March 24, 2005 02:47PM

I'm having a little trouble with GROUP BY

I want to return a list of only the most recent invoices for every customer. I've tried

SELECT InvoiceNumber, CustomerID, InvoiceDate
FROM bookings
GROUP BY CustomerID, InvoiceDate DESC;

But this returns every invoice. It does at least have the latest invoice first, but really I want to drop all older invoices.

How do I achieve this?

Options: ReplyQuote


Subject
Written By
Posted
Problem with GROUP BY
March 24, 2005 02:47PM
March 24, 2005 04:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.