so we will need to update the "updateto" field following way
for row 1) we compare AD and hub and since hub is null updateto = AD
row 2 ) we compare AD with hub and since AD is null updateto = hub
row 3 ) we compare AD and hub with hb . since AD matches hb updateto = AD
row 4 ) we compare AD and hub with hb and since they all three are same we compare addate with hubdate and since hubdate is higher updateto = hub
there are more then 4 rows in the table. I have just given an example over here.
how do i write a sql statement to make this happen.