SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead ,E.SName AS SchoolName,c.CateName,E.ManagerId
SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead ,E.SName AS SchoolName,c.CateName,E.ManagerId,IFNULL(t.GuestNum,0) AS OrderStudentCount
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
LEFT JOIN rb_course_category c on b.CateId = c.CateId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
LEFT JOIN (SELECT ClassId,SUM(GuestNum) AS GuestNum FROM rb_order WHERE OrderState IN (1,2) GROUP BY ClassId)t on A.ClassId = t.ClassId
WHERE 1=1
");
if(query!=null)
...
...
@@ -106,6 +107,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.School_Id),query.School_Id);
}
if(query.CouseId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.CouseId),query.CouseId);
}
if(query.ClassId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.ClassId),query.ClassId);