Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    7

    Unanswered: Help with selecting max date for records

    This is driving me crazy, if anyone can help it will be much appreciated.

    Basically, I have two columns: date and value.

    Date Value
    1/1/2003 10
    1/2/2003 11
    1/3/2003 12

    I want the last date's (1/3/2003) value. How the heck do I do this in SQL and WITHOUT using a sub select to get the maximum date? Can it be done?

    Cheers.

  2. #2
    Join Date
    Oct 2002
    Posts
    7
    Sorry, my fault, I should have worded it better.

    Given:

    Key Date Value
    1 1/1 10
    1 1/2 11
    1 1/3 12
    2 1/1 20
    2 1/2 30
    2 1/3 40
    2 1/4 50

    My result should be:

    1,12
    2,50

  3. #3
    Join Date
    Jun 2003
    Posts
    34

    Try This!!

    select substr(max(cdate||key||value),length(cdate)+1,1),s ubstr(max(cdate||key||value) key ,length(cdate||key)+1) value
    from test
    Originally posted by alougher
    Sorry, my fault, I should have worded it better.

    Given:

    Key Date Value
    1 1/1 10
    1 1/2 11
    1 1/3 12
    2 1/1 20
    2 1/2 30
    2 1/3 40
    2 1/4 50

    My result should be:

    1,12
    2,50

Posting Permissions

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