,MIN(A.StartTime) AS StartTime,MAX(A.EndTime) AS EndTime,
,MIN(A.StartTime) AS StartTime,MAX(A.EndTime) AS EndTime,A.ChapterNo as Ranks
(SELECT COUNT(*) from rb_class_plan p inner join rb_scroll_appointment s on p.ClassPlanId = s.ClassPlanId where p.`Status`=0 and p.PlanType =2 and s.StuId ={2} and DATE_FORMAT(p.ClassDate,'%Y-%m-%d') <=DATE_FORMAT(a.ClassDate,'%Y-%m-%d') and p.CourseId=a.CourseId) as Ranks
FROM
FROM
(
(
SELECT A.ClassPlanId,sa.StuId, A.CourseId,A.ClassDate,A.ClassRoomId,C.CourseName,IFNULL(D.TeacherName,'') AS TeacherName
SELECT A.ClassPlanId,sa.StuId, A.CourseId,A.ClassDate,A.ClassRoomId,C.CourseName,IFNULL(D.TeacherName,'') AS TeacherName
,IFNULL(D.TeacherHead,'') AS UserIcon,E.RoomName,F.StartTime,F.EndTime
,IFNULL(D.TeacherHead,'') AS UserIcon,E.RoomName,F.StartTime,F.EndTime,sa.ChapterNo
FROM rb_class_plan AS A
FROM rb_class_plan AS A
INNER JOIN rb_scroll_appointment sa on A.ClassPlanId = sa.ClassPlanId and sa.StuId ={2}
INNER JOIN rb_scroll_appointment sa on A.ClassPlanId = sa.ClassPlanId and sa.StuId ={2}