Хранимая процедура , случай, когда условие не выполняется
I amupdating INTIme and OUTTime in a table of Employee attendance using Update store Procedure,INTIME and OUTTIME is getting updated in a table ,but further query for calculating Hours and OT,OTAmount and Late which is base on case when condition is not working .
Что я уже пробовал:
<pre>Update EmployeesAttendance set EmployeesAttendance.INTIME=@INTime, EmployeesAttendance.OUTTIME=@OUTTIME, EmployeesAttendance.Hours= ( (DATEDIFF(Hour,OUTTIME,INTIME))), EmployeesAttendance.Days =( CASE WHEN EmployeesAttendance.Hours >= EmployeeDetails.Dhour THEN 1 WHEN EmployeesAttendance.Hours = 0 THEN 0 WHEN EmployeesAttendance.Hours >= 6 THEN 0.5 end), EmployeesAttendance.OT=(CASE WHEN EmployeesAttendance.Hours > EmployeeDetails.Dhour then EmployeesAttendance.Hours - EmployeeDetails.Dhour else 0 End), EmployeesAttendance.OTAmount =(CASE when EmployeeDetails.OTEntitled = 'Yes' AND EmployeesAttendance .Hours >= EmployeeDetails.Dhour THEN (( EmployeesAttendance.Hours - EmployeeDetails.Dhour) * 100) else 0 END ), EmployeesAttendance.Time=( Convert(varchar(10),EmployeesAttendance.INTIME,108)), EmployeesAttendance.Late=(Case When Convert(Time, EmployeesAttendance .INTIME,108) > EmployeeDetails.LTime Then 1 else 0 end) From EmployeeDetails INNER Join EmployeesAttendance ON EmployeeDetails.EmpId = EmployeesAttendance.EmpID -- Order by EmployeeDetails.EmpID asc where EmployeesAttendance.AttIDS=@AttIDS end
MadMyche
Первое, что я бы сделал, это использовал псевдонимы для имен таблиц, а затем отформатируйте свой код, как это было показано в ответах на другие ваши вопросы.