sql - Update and self join -


i want update blank name column in client table using non-blank column same client number. know how should modify below sql? thanks,

update client     set name=(select name client (name not null , name<>'') ) client c1, client c2 (name null or name='') , c1.client_no=c2.client_no 

i recommend using window functions purpose:

with toupdate (       select c.*, max(name) on (partition client_no) maxname       client c      ) update toupdate     set name = maxname     name null or name = ''; 

Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -