case when og.TotalHours <= og.CompleteHours then 3 else
case when og.CompleteHours = 0 then 1 else
case when og.TotalHours > og.CompleteHours then 2 else 0 end end end as ClassStatus,
sch.SName,sch.SId,t.TeacherName,o.EnterID,og.TotalHours,og.CompleteHours, if((og.ValidClassHours-og.CompleteHours)<0,0,(og.ValidClassHours-og.CompleteHours)) as SurplusHours
case when og.TotalHours <= og.CompleteHours then 3 else
case when og.CompleteHours = 0 then 1 else
case when og.TotalHours > og.CompleteHours then 2 else 0 end end end as ClassStatus,
sch.SName,sch.SId,t.TeacherName,o.EnterID,og.TotalHours,og.CompleteHours, if((og.ValidClassHours-og.CompleteHours)<0,0,(og.ValidClassHours-og.CompleteHours)) as SurplusHours
,cou.OpenBankLevel
FROM rb_student as s LEFT JOIN rb_student_orderguest as sog on s.StuId=sog.Student_Id
LEFT JOIN rb_order_guest as og on og.Id=sog.GuestId