Update field A with the lesser value between field B and C?

  • I need to evaluate 2 fields in the same table and update a third field in the same table with the lesser value of the compared fields

    Ie, check field A against field B, which ever is less (integer) update field C with the lesser value.

    Thanks all.

  • I'd use a CASE statement like the following.

    update table1

    set column3 = CASE WHEN column1 < column2 THEN column1 ELSE column2 END

  • Thanks Tony!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply