select t1.AttendanceDate, t1.EmployeeCode, case when t2.duration is null then t1.duration else t2.duration end
from table1 t1 left outer join table t2 on t1.AttendanceDate= t2.AttendanceDate and t1.EmployeeCode = t2.EmployeeCode
-1
这应该工作 .
SELECT Table1.AtendanceDate, Table1.EmployeeCode,
CASE WHEN Table2.Duration IS NOT NULL THEN Table2.Duration ELSE Table1.Duration END AS Duration
FROM Table1
LEFT OUTER JOIN Table2 ON Table1.AtendanceDate = Table2.AtendanceDate
AND Table1.EmployeeCOde = Table2.EmployeeCode
2 回答
试试这个未经测试的查询:
这应该工作 .