2021年4月23日星期五

SQL Transformation - DB2

I have a dataset in DB2. The PK column is PK_Ind and there is a Logic_Ind column as well. The transformation I am looking for is for the same PK column if Logic_Ind is NULL then try to find a match where END_DATE of that specific row is BETWEEN START_DATE and END_DATE of any other row for same PK_Ind and Logic_Ind is NOT NULL (i.e. Logic_Ind='A'). If match found then the values for Col1, Col2 and Col3 should be taken and populated for the row where Logic_Ind is NULL.

In the below example 3rd row should find a match with 2nd row and 7th row should match with 4th row and Col1, COl2 and Col3 should reflect the modified values 3rd and 7th row.

But if there is no match found then still the same record should be presented as it is in the source dataset.

Source dataset: enter image description here

Target dataset: enter image description here

https://stackoverflow.com/questions/67237603/sql-transformation-db2 April 24, 2021 at 06:40AM

没有评论:

发表评论