0

我需要您的支持。我想将其更改为更新语句,我想使用 PersonDeatl 的 Birthage 更新 E.Age 的所有空值。下面的脚本只是选择 .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)
4

1 回答 1

0

You can try this.

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 
于 2012-10-26T18:03:56.143 回答