Kevin J. Bowman wrote:

> Result Set I Am Looking For
>
> CUSTOMER  TRANSACTION DATE    TRANSACTION CODE
> Alpha     01/07/2005          3    
> Bravo     01/07/2005          7
> Charlie   01/01/2005          3
>
> This is a simplified version of my actual data.  But I should be able
> to write the real query I need, if someone can explain the logic of
> the query to me using this example.

You'll have to do it with inlining another select.  This works with my 
MySQL version 4.1.9:

SELECT customers.name,date,code FROM customers, (SELECT name,max(date) 
AS maxdate FROM customers GROUP BY name) AS maxdates WHERE 
customers.name=maxdates.name AND date=maxdate;

The basic idea is to join your table with a another table you create on 
the fly, i.e. the table with the maximum date for each customer.  From 
the original table you then select the record that joins with the 
maxdates table.  The assumption ofcourse is that there is only one entry 
per date per customer.

Rgds,
Carl




The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to