LEFT JOIN rb_education_contract ec on ec.GuestId = og.GuestId
LEFT JOIN rb_student_advisorconfig AS b ON s.AdvisorStatus=B.Id
LEFT JOIN (SELECT OrderGuestId,MIN(ClassDate) AS ClassDate FROM rb_class_check WHERE Status=0 AND CheckStatus=0 GROUP BY OrderGuestId) AS clcheck ON org.Id=clcheck.OrderGuestId
LEFT JOIN (
SELECT B.Student_Id,MIN(A.ClassDate) AS ClassDate
FROM rb_class_check AS A INNER JOIN rb_student_orderguest AS B ON A.OrderGuestId=B.GuestId
WHERE A.Status=0 AND A.CheckStatus=0 GROUP BY B.Student_Id