Results 1 to 3 of 3

Thread: Date Selection

  1. #1
    Join Date
    Apr 2006
    Posts
    3

    Question Unanswered: Date Selection

    I have 20 rows in a database made up of 5 different names, so I have 4 rows with the same name the only difference being that they have a different date and address. How do I create a query to select the name and address based on the latest date for each of the different names.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Code:
    select name, address
    from   mytable t1
    where  t1.datecol = (select max(t2.datecol)
                         from   mytable t2 
                         where  t2.name = t1.name
                        );

  3. #3
    Join Date
    Apr 2006
    Posts
    3
    Many thanks for the reply, tried it and it worked perfectly to give me the information I required.

Posting Permissions

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