INNER JOIN rb_order_guest og on sog.GuestId = og.Id
INNER JOIN rb_order o on sog.OrderId = o.OrderId
left join rb_course c on o.CourseId = c.CourseId
WHERE a.`Status` =0 and a.Group_Id ={groupId} and a.AccountType =4 and og.GuestState not in(2,7) and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours
WHERE a.`Status` =0 and a.Group_Id ={groupId} and a.AccountType =4 and case when o.CourseId =1 then 1=1 else og.GuestState not in(2,7) end and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours