Page 1 of 1

Populate values of next record in previous record

Posted: Sat Sep 09, 2017 8:01 pm
by manojbh31
Hello all,

I have 5 records as below

Code: Select all

Id      Date           End date
1234    2017-08-09     2017-08-10
1234    2017-08-10     2017-08-11
1234    2017-08-11     2017-08-12
1234    2017-08-12     2017-08-13
1234    2017-08-13     2099-12-31
I need to pick next record date value and populate in end date of old record as above, please help on how to implement this .

Posted: Sat Sep 09, 2017 11:52 pm
by chulett
Go in reverse order.

Posted: Sun Sep 10, 2017 5:39 am
by manojbh31
Craig,

I am not getting you, please explain.

Posted: Sun Sep 10, 2017 8:41 am
by chulett
You can't do anything with the "previous" records unless we're talking a database as the target. I'm assuming we're talking about files here so the suggestion is to sort the data descending... i.e. process them in the opposite order posted so that the date in the current record can be used as the date in the next record rather than the previous one.

Posted: Sun Sep 24, 2017 7:20 am
by Timato
On the offchance you are sourcing from a database i'd suggest reading up on 'window' functions for your rdbms. Perfect for reconstructing SCDs (i assume...)