Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    7

    Unanswered: SQL statement help

    Hello I have a table structure like below

    ID Date
    ----------------
    2 9/17/2003
    2 8/17/2003
    30 9/17/2003
    45 2/17/2002

    I would like to get a list of IDs and Dates from the table with the newest date row only for distinct IDs

    so the results would look like this

    2 9/17/2003
    30 9/17/2003
    45 2/17/2002

    Thanks in advance,
    Coop

  2. #2
    Join Date
    Sep 2003
    Posts
    7
    try this,

    select
    *
    from
    table
    group by
    ID
    HAVING
    Date = MAX(Date)

  3. #3
    Join Date
    Jan 2003
    Posts
    7
    sorry found the answer earlier, thanks for the post anyways

    select * from table1 t group by id, date having date = (select
    max(date)
    from t1 where id=t.id)


    Brad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •