Hello,
I am trying to sum values of two different database tables using join operation but after that I am getting a wrong sum value.
Ex: db1.tbl1.sum = 20 and db2.tbl1.sum = 40 then sum = 60
but i am getting wrong sum = 1024312
below is my code kindly correct me
select sum(case when w.Status_Type !=4 then 1 else 0 end) + sum(case when m.Status_Type !=4 then 1 else 0 end) as total
from hkrdb.dbo.works w right join Macro.dbo.works m on w.DIST_code = m.DIST_code where w.DIST_code = 1