Updating column with values from the same table

From: Jens Riedel <jensrie_at_gmx.de>
Date: Thu, 17 Jan 2013 08:38:04 +0100
Message-ID: <alpo2sFigrdU1_at_mid.individual.net>



Hi,

I'm looking for an update statement that allows me the following operation:

I have a table where I have records for each day with the fields 'day_date', 'ID', 'my_value'.
When a new record comes in for the current day I want to update the field 'my_value' with the corresponding value from the previous day's record with the same ID - if it exists, sometimes there are new records that have no equivalent already.

An example:

Record for today: 2013-01-17 ; 4711 ; null

-> set the third field to the value that is in 'my_value' from the
record ' 2013-01-16 ; 4711; xyz ' or leave it null if this record doesn't exist.

I appreciate any idea how to achieve this.

Thanks and regards
Jens Received on Thu Jan 17 2013 - 08:38:04 CET

Original text of this message