Monday 15 April 2013

sql - Update one row with other row data from same table in Oracle -


I have a table with 90 columns and I want to update / empty columns with value from the most preceding record For specific group

For example: I have to update empty columns with all non-id = 8 Value (IDPK ascending order). If the previous record is zero then the next preceding record and so on.

Similar to Grp2 , update the record where id = 15 with the group before the archives and so on ...

Trouble I'm about to check and update about 90 columns. Instead of singling out there is no particular way to check each column and previous record value.

Thank you for looking at the question.

Below is a subset of that table

  DT type FLG due to Group ID_PK tax ===== ============== ================= Grp1 2 1 6/3/2013 0 SDN Group 1 3 18813 1 MEM Group 1 5 1 SDHC N Group 1 8 No Grap 2 9 12713 3 5 / 20/2014 SDHC Y Grap 2 11 NOR N Grapepi 2 15 12713  

I have There is no Oracle database instance to confirm 100% that this works, but the function that you are looking for is the interval ()

This issue is going to be made for you that you need to go behind the different lines depending on the number of records required to come before a nonsense value. You can write a very long case statement that will work, but sub optimal but, interval () what you want.


No comments:

Post a Comment