stringsql=$@"SELECT o.EnterID,SUM(o.PreferPrice) as PreferPrice,SUM(o.Income) AS Income,sum(o.PlatformTax) as PlatformTax,SUM(o.Refund) AS Refund,SUM(o.GuestNum) AS GuestNum,
SUM(CASE WHEN c.ClassStatus =3 then o.GuestNum else 0 END) AS JKNum,COUNT(0) AS CancelNum, SUM(IFNULL(ttt.XFMoney,0)) AS YSKMoney
FROM rb_order o
LEFT JOIN rb_class c on o.ClassId = c.ClassId
LEFT JOIN (SELECT q.OrderId,
SUM((case when q.ClassHours>0 and q.TotalSub >0 then
+ec.FirstClassFee + ec.SecondClassFee + ec.ThirdClassFee as TotalSub
,ec.FirstClassHours + ec.SecondClassHours + ec.ThirdClassHours as ClassHours
,cc.CurrentDeductionHours
FROM rb_order_guest g
INNER JOIN rb_education_contract ec on g.Id = ec.GuestId
LEFT JOIN (SELECT ch.OrderGuestId, SUM(ch.CurrentDeductionHours) AS CurrentDeductionHours FROM rb_class_check ch WHERE `Status` =0 GROUP BY ch.OrderGuestId) cc on cc.OrderGuestId = g.Id
)q GROUP BY q.OrderId) ttt on ttt.OrderId = o.OrderId
WHERE o.Group_Id={group_Id} and o.OrderState <> 3 and o.EnterID >0 {where} and o.CreateTime >='{startMonth}' and o.CreateTime <='{endMonth}'
GROUP BY o.EnterID ORDER BY SUM(o.Income + o.PlatformTax - o.Refund) DESC
stringsql=$@"SELECT o.EnterID,SUM(o.PreferPrice) as PreferPrice,SUM(o.Income) AS Income,sum(o.PlatformTax) as PlatformTax,SUM(o.Refund) AS Refund,SUM(o.GuestNum) AS GuestNum,
SUM(CASE WHEN c.ClassStatus =3 then o.GuestNum else 0 END) AS JKNum,COUNT(0) AS CancelNum, SUM(IFNULL(ttt.XFMoney,0)) AS YSKMoney
FROM rb_order o
LEFT JOIN rb_class c on o.ClassId = c.ClassId
LEFT JOIN (SELECT q.OrderId,
SUM((case when q.ClassHours>0 and q.TotalSub >0 then
+ec.FirstClassFee + ec.SecondClassFee + ec.ThirdClassFee as TotalSub
,ec.FirstClassHours + ec.SecondClassHours + ec.ThirdClassHours as ClassHours
,cc.CurrentDeductionHours
FROM rb_order_guest g
INNER JOIN rb_education_contract ec on g.Id = ec.GuestId
LEFT JOIN (SELECT ch.OrderGuestId, SUM(ch.CurrentDeductionHours) AS CurrentDeductionHours FROM rb_class_check ch WHERE `Status` =0 GROUP BY ch.OrderGuestId) cc on cc.OrderGuestId = g.Id
)q GROUP BY q.OrderId) ttt on ttt.OrderId = o.OrderId
WHERE o.Group_Id={group_Id} and o.OrderState <> 3 and o.EnterID >0 {where} and o.CreateTime >='{startMonth}' and o.CreateTime <='{endMonth}'
GROUP BY o.EnterID ORDER BY SUM(o.Income + o.PlatformTax - o.Refund) DESC