stringsql=$@"SELECT t.ClassId,SUM(t.CurrentDeductionHours) AS CurrentDeductionHours FROM(
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.ClassDate,p.ClassTimeId,MAX(p.CurrentDeductionHours) as CurrentDeductionHours
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.ClassDate,p.ClassTimeId,MAX(p.CurrentDeductionHours) as CurrentDeductionHours,t2.OrderId
FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
LEFT JOIN rb_order_guest t2 on p.OrderGuestId = t2.Id
WHERE p.`Status` =0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end GROUP BY case when cp.PlanType=2 then t2.ClassId else p.ClassId end,p.ClassDate,p.ClassTimeId
WHERE p.`Status` =0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end GROUP BY case when cp.PlanType=2 then t2.ClassId else p.ClassId end,p.ClassDate,p.ClassTimeId,t2.OrderId