Results 1 to 3 of 3
  1. #1
    Join Date
    May 2008
    Posts
    35

    Unanswered: Getting 2nd Last Row from Table.

    I'm trying to get the last second last row of each record entry from a table but unable to get accurate records.

    Table Schema , all are non-unique

    Col 1 Col2 Col3
    1 A 18:00
    1 B 18:30
    2 A 14:00
    3 B 16:00
    2 C 18:00

    What i want is to get the details of all 3 colums depending on max of Col3 So It should show like this.
    1 B 18:30
    2 C 18:00
    3 A 18:00
    Last edited by dinjo_jo; 01-29-09 at 01:39.

  2. #2
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    Try:

    SELECT col1, col2, col3
    FROM tbl t1
    WHERE col3 =
    (SELECT MAX(col3)
    FROM tbl t2
    WHERE t1.col1 = t2.col1);

  3. #3
    Join Date
    May 2008
    Posts
    35
    Thank You very much

Posting Permissions

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