merge into B target using (select max(adat) adat, id from a where adat is not null group by id) source
on (target.id=source.id)
when matched then set target.adat=source.adat;