Need help about writting a query:

  • I have a table, which record some user's update status information. Everytime, when a user update his status, a record is inserted to table. The record only contains user Id, user name and user update date. So in table, I have bounch of records like this:

    IDNameUpdate Date

    001Jerry11/01/2011

    001Jerry11/03/2011

    002John10/23/2011

    003Tom11/02/2011

    003Tom11/06/2011

    003Tom11/07/2011

    ...

    Now I need to write a query to find out all users who has updated their status, but if a user updated his stauts more than once, only the record when he first record should be returned. In this case, the result of query should be something like:

    IDNameUpdate Date

    001Jerry11/01/2011

    003Tom11/02/2011

    ....

    I am not good on SQL query....Any suggestion are highly appreciated. Thanks a lot in advance!

  • does this help...

    SELECT ID, Name, MIN(Update_date)

    FROM <YOURTABLE>

    GROUP BY ID, Name

    HAVING (COUNT(*) > 1)

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Hey, dude, that helps. Thanks a lot.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply