-3

enter image description here

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..

Ankur Alankar Biswal
  • 1,184
  • 1
  • 12
  • 23

2 Answers2

2

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
Jens
  • 67,715
  • 15
  • 98
  • 113
-1

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
LeeG
  • 708
  • 5
  • 14