In this Table1 and Table2 (AttendanceDate,EmployeeCode) are PRIMARY Key.. How can we replace table1 value with table2 where ever AttendanceDate and EmployeeCode will match..
Like Result table..
In this Table1 and Table2 (AttendanceDate,EmployeeCode) are PRIMARY Key.. How can we replace table1 value with table2 where ever AttendanceDate and EmployeeCode will match..
Like Result table..
try this untested query:
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
This should work.
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