update A_SalaryConsolidated set bonus=case when a.final_payable >bonus then bonus else (bonus+a.final_payable) from (select empid,final_payable from Bonus inner join monthdigit on month=monthView where monthnumber= 5 and year = 2017 and Bonus.empid in(select a.empid from(select empid from Bonus inner join monthdigit on month=monthView where monthnumber=5 and year=2017 and final_payable>0 and unitid=145) as a )) as a inner join A_SalaryConsolidated on a.empid=A_SalaryConsolidated.staffid where month ='July' and year = '2017'
end
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)