self-join, group by, single SQL query

2003-11-11 Thread Robert Citek
Hello all, Is there a way to do a self-join and a group by in a single SQL query? For example, I have an PurchaseOrder table (see below) and would like to know what was the most recent order-number for each customer and the amount of that order. So far, I have been able to do this in two

Re: self-join, group by, single SQL query

2003-11-11 Thread Roger Baklund
* Robert Citek Is there a way to do a self-join and a group by in a single SQL query? Yes, but I'm not sure if that is what you need... For example, I have an PurchaseOrder table (see below) and would like to know what was the most recent order-number for each customer and the amount of that

Re: self-join, group by, single SQL query

2003-11-11 Thread Robert Citek
On Tuesday, November 11, 2003, at 03:06 PM, Roger Baklund wrote: * Robert Citek Is there a way to do a self-join and a group by in a single SQL query? See the max-concat trick, described here: URL: http://www.mysql.com/doc/en/example-Maximum-column-group-row.html Thanks for the tip. It looks