Read one row of table emplyee_table with company_table  matching(similar) EmpID, Name , Amount_ID and year  check the "amount" of each row having same matching EmpID, Name , Amount_ID and year   doesnt exceed with company_table "amount" if the amount of employee_table exceed company_table.. (if e.amt>c.amt) {  validatiion- that row will not update  } else  if the amount of employee_table is same  company_table (if e.amt=c.amt) { update that particular row into (company_details_table) } else   if the amount of employee_table is same  company_table (if e.amt<c.amt) { update that particular row into (company_details_table) }

Go to the complete details ...