Re: Newbie MySQL question: how to retrieve latest entry from a history of entries?

From: davout (davZZZYYYXXXout_at_dial.pipex.com)
Date: 08/25/04


Date: Wed, 25 Aug 2004 18:07:13 +0100

Can't see how that helps me. The problem is more complicated than you think.
I'm not requesting entries for a given date. Instead its the most recent
date for each station. My original example has been expanded to show how
this impacts the 'Manchester' data

e.g.
        1, London
        2, Brighton
        3, Manchester

table: stationstatus
Fields: StationID, StatusDate, Metric1,Metric2,Metric3

e.g.

    1, 23/8/04, 1, 1, 1
    1, 24/8/04, 2, 2, 2
    1, 25/8/04, 3, 3, 3
    2, 23/8/04, 4, 4, 4
    2, 24/8/04, 5, 5, 5
    2, 25/8/04, 6, 6, 6
    3, 24/8/04, 7, 7, 7

What I'm looking for is a query that returns

    StationID,StationName,StatusDate,Metric1,Metric2,Metric3

e.g.

    1, London, 25/8/04, 3, 3, 3,
    2, Brighton, 25/8/04, 6, 6, 6
    3, Manchester, 24/8/04, 7, 7, 7

Thoughts?

"Flip" <[remove]phenry_w@hotmail.com> wrote in message
news:6j2Xc.1689$KF.13174@tor-nn1.netcom.ca...
> What about adding a Timestamp col to the stationstatus table? Maybe call
is
> ts, and that way you can order by that column for newest/oldest in the
sql.
>
>