SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead,E.SName AS SchoolName,R.RoomName,IFNULL(t.GuestNum,0) as OrderStudentCount
SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead,E.SName AS SchoolName,R.RoomName
FROM rb_class AS A
,IFNULL(t.GuestNum,0) AS OrderStudentCount
LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_class_room AS R ON A.ClassRoomId=R.RoomId
LEFT JOIN rb_class_room AS R ON A.ClassRoomId=R.RoomId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
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
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
WHERE 1=1
");
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Status),0);
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Status),0);
...
@@ -264,6 +264,11 @@ WHERE 1=1
...
@@ -264,6 +264,11 @@ WHERE 1=1
{
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.CouseId),query.CouseId);
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.CouseId),query.CouseId);
}
}
//课程分类编号
if(query.CateId>0)
{
builder.AppendFormat(" AND B.{0}={1} ",nameof(RB_Class_ViewModel.CateId),query.CateId);
}
if(query.Teacher_Id>0)
if(query.Teacher_Id>0)
{
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Teacher_Id),query.Teacher_Id);
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Teacher_Id),query.Teacher_Id);