Assuming the invoice numbers increase each time, you can use MAX() and
GROUP BY to get what you need.

SELECT customer, MAX(invoiceNum) AS lastNum
FROM table
GROUP BY customer

If invoices are not numbered sequentially, hopefully you have a date
field that you can add to the grouping.

M!ke 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 04, 2007 7:58 AM
To: CF-Talk
Subject: SQL Query Help 

having brain fart here ... ughh

scenario: customer table, invoice table

I'd like to do a query to list the last invoice for each customer.

Can someone point me in the right direction please?

TIA,
Jenny

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274520
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to