Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003

    Question Unanswered: Update a record with highest date

    I am trying to select a record out of 40 with the highest date, to update. How should I do this.

    col1 col2 col3 col3
    ab1 xy2 lm3 date1
    ab1 xy4 lm3 date1
    ab1 xy5 lm3 date2 (higherst)
    ab1 xy6 lm3 date1

    I would like to selct the record for highest date2 and update lm3 to lm33.

    How do I do this?

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    Post DDL for table.
    Post DML for test data.
    Post expected/desired results (that matches test data).
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Something like
    update your_table t1 set
      t1.col3 = lm33
    where t1.col4 = (select max(t2.col4)
                     from your_table t2
                     where t2.col1 = t1.col1
    In other words: find the maximum COL4 date (possibly for every COL1 - thus the WHERE clause) and update this record's COL3 column to a new value.

  4. #4
    Join Date
    Nov 2003
    Thank you folks. I am sorry I wasnt able to respond sooner.

Posting Permissions

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