@@ -235,8 +235,13 @@ from RB_Sell_Achievements_Details r where {where} order by r.Id asc";
...
@@ -235,8 +235,13 @@ from RB_Sell_Achievements_Details r where {where} order by r.Id asc";
}
}
stringsql=$@" select r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney
stringsql=$@" select r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept,p.RuleId,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney
from RB_Sell_Achievements_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept";
from RB_Sell_Achievements_Details r
left join(
select e.OrderId,e.EmpId,max(e.RuleId) as RuleId from rb_sell_achievements_emp e group by e.OrderId,e.EmpId
) p on r.OrderId = p.OrderId and r.UserId = p.EmpId
where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept";