By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE mytable(
EID INTEGER
,Hold VARCHAR(20) NOT NULL
,Source VARCHAR(100) NOT NULL
);
INSERT INTO mytable(EID,Hold,Source) VALUES
(3232,'KLME','jame.k@gmail.com'),
(NULL,'KLME','https://google.com'),
(NULL,'EEME','david.e@gmail.com'),
(NULL,'JJIN','Test@gmail.com'),
(7232,'JJIN','https://google.com');
5 rows affected
update m1
set m1.EID=iif(m1.EID is null,m2.EID,m1.EID)
from mytable m1
join mytable m2
on m1.Hold=m2.Hold and m1.Source<>m2.Source
4 rows affected
select * from mytable
EID | Hold | Source |
---|---|---|
3232 | KLME | jame.k@gmail.com |
3232 | KLME | https://google.com |
null | EEME | david.e@gmail.com |
7232 | JJIN | Test@gmail.com |
7232 | JJIN | https://google.com |