stringwhere=" 1=1 and s.Status =0 and c.CourseId <>1";//排除内部班
stringwhere=" 1=1 and s.Status =0 and c.CourseId <>1";//排除内部班
if(demodel.Group_Id>0)
if(demodel.Group_Id>0)
...
@@ -682,26 +683,28 @@ FROM rb_student s
...
@@ -682,26 +683,28 @@ FROM rb_student s
where+=$" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";
where+=$" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";
}
}
}
}
stringjoinType="INNER JOIN";
if(demodel.QueryTpye==3)
{
joinType="LEFT JOIN";
}
stringsql=$@"
stringsql=$@"
select count(0) as OrderCount,sum(case when t.RenewState = 1 then 1 else 0 end) AS RenewOrderCount,
SELECT count(0) as OrderCount,sum(case when t.RenewState = 1 then 1 else 0 end) AS RenewOrderCount,
SUM(CASE WHEN t.StuGuestState in(1,3,4,6,8,9) THEN 1 ELSE 0 END) AS StudyNum,
SUM(CASE WHEN t.StuGuestState in(1,3,4,6,8,9) THEN 1 ELSE 0 END) AS StudyNum,
SUM(CASE WHEN t.StuGuestState =2 THEN 1 ELSE 0 END) AS DropOutNum,
SUM(CASE WHEN t.StuGuestState =2 THEN 1 ELSE 0 END) AS DropOutNum,
SUM(CASE WHEN t.StuGuestState =5 THEN 1 ELSE 0 END) AS SuspendNum,
SUM(CASE WHEN t.StuGuestState =5 THEN 1 ELSE 0 END) AS SuspendNum,
SUM(CASE WHEN t.StuGuestState =7 THEN 1 ELSE 0 END) AS GraduateNum
SUM(CASE WHEN t.StuGuestState =7 THEN 1 ELSE 0 END) AS GraduateNum
from(
FROM(
SELECT s.StuId,s.StuName,s.StuTel,s.StuRealMobile,s.QQ,ec.CreateTime,c.CourseId,c.CourseName,s.JapanBaseInfo,s.StuBirth,org.GuestState as StuGuestState,
case when o.RenewOrderId >0 or org.RenewState =2 then 1 else 0 end AS RenewState
,org.GuestState as StuGuestState,case when o.RenewOrderId >0 or org.RenewState =2 then 1 else 0 end AS RenewState
FROM rb_student s
FROM rb_student s
INNER JOIN rb_student_orderguest og on og.Student_Id = s.StuId
{joinType} rb_student_orderguest og on og.Student_Id = s.StuId
INNER JOIN (SELECT og.Student_Id,MAX(og.Id) as Id FROM rb_student_orderguest og
{joinType} (SELECT og.Student_Id,MAX(og.Id) as Id FROM rb_student_orderguest og INNER JOIN rb_order o on og.OrderId = o.OrderId WHERE o.OrderState <>3 GROUP BY og.Student_Id) stu on og.Id = stu.Id and og.Student_Id = s.StuId
INNER JOIN rb_order o on og.OrderId = o.OrderId
{joinType} rb_order_guest org on org.Id = og.GuestId
WHERE o.OrderState <>3 GROUP BY og.Student_Id) stu on og.Id = stu.Id and og.Student_Id = s.StuId
{joinType} rb_order o on og.OrderId = o.OrderId
INNER JOIN rb_order_guest org on org.Id = og.GuestId
{joinType} rb_class cl on cl.ClassId = o.ClassId
INNER JOIN rb_order o on og.OrderId = o.OrderId
{joinType} rb_course c on o.CourseId = c.CourseId
inner join rb_class cl on cl.ClassId = o.ClassId
LEFT JOIN rb_education_contract ec on ec.GuestId = og.GuestId ";
INNER JOIN rb_course c on o.CourseId = c.CourseId
LEFT JOIN rb_education_contract ec on ec.GuestId = og.GuestId";