我需要你的支持。我想把它更改为更新语句,我想用PersonDeatl更新E.Age的所有空值和Birthage。下面的脚本只选择.Table Employee和PersonDeatl没有键加入他们或加入EmpRet.Thanks人
select distinct * from ((Select
E.EmployeeId,E.Address,E.City,E.Zip,E.State,E.Age
from Employee E join
EmpRet R
on E.EmployeeId=R.EmployeeId
where R.Dscription='Age not Qualify' and E.Age is null)Ag inner join
(select address,city,zip,state,BirthAge from PersonDeatl)Pd
on ag.Address=Pd.Address and ag.City=Pd.City and ag.zip=Pd.Zip)
答案 0 :(得分:0)
你可以试试这个。
With EmpCTE ( Age, BirthAge ) as (
SELECT E.Age, P.BirthAge
FROM Employee E
JOIN PersonDeatl P
ON E.Address = P.Address
AND E.City=P.City
AND E.Zip=P.Zip
Where E.Age IS NULL
)
UPDATE EmpCTE
SET Age = BirthAge