join rb_class_plan d on c.ClassPlanId = d.ClassPlanId
// join rb_class_plan d on c.ClassPlanId = d.ClassPlanId
where d.ClassDate < b.ClassDate and c.ClassId = b.ClassId)
// where d.ClassDate < b.ClassDate and c.ClassId = b.ClassId)
from rb_class_plan b where b.ClassPlanId = "+planId+" and b.`Status`= 0";
//from rb_class_plan b where b.ClassPlanId = " + planId + " and b.`Status`= 0";
stringsql="select (select Count(0) from rb_class_plan b where b.ClassId=a.ClassId and b.ClassDate<a.ClassDate) from rb_class_plan a where ClassPlanId="+planId+" and `Status`=0";
builder.AppendFormat(" AND {0}={1}",nameof(RB_Course_Chapter_ViewModel.Status),EnumHelper.ToInt(DateStateEnum.Normal));
builder.AppendFormat(" AND {0}={1}",nameof(RB_Course_Chapter_ViewModel.Status),EnumHelper.ToInt(DateStateEnum.Normal));
builder.AppendFormat(" AND {0}={1}",nameof(RB_Course_Chapter_ViewModel.CourseId),courseId);
builder.AppendFormat(" AND {0}={1}",nameof(RB_Course_Chapter_ViewModel.CourseId),courseId);
builder.AppendFormat(" AND {0}<={1}",nameof(RB_Course_Chapter_ViewModel.CurrentHours),currentHours);
builder.AppendFormat(" AND ({0}='{1}' or {2} like '{3}.%')",nameof(RB_Course_Chapter_ViewModel.ChapterNo),currentHours,nameof(RB_Course_Chapter_ViewModel.ChapterNo),currentHours);
builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));
//builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));