select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as course_name
from ex_course_phase a
left join ex_course b on b.id=a.course_id
update ex_course_phase set del_flag=1 where id=#{phaseId}
select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
b.name as course_name,c.name as company_name,
(select count(1) from ex_phase_student where phase_id=a.id) as student_count
from ex_course_phase a
left join ex_course b on b.id=a.course_id
left join sys_company c on c.id=a.company_id
and a.del_flag=0
AND a.name like concat('%', #{name}, '%')
AND a.code like concat('%', #{code}, '%')
AND a.company_id =#{companyId}
AND a.course_id =#{courseId}
AND a.level =#{level}
order by a.create_time desc
where a.id=#{phaseId}
select id,name from ex_course_phase where del_flag=0 and name=#{name} limit 1
select count(1) from ex_course_phase where del_flag=0 and courde_id=#{courseId}
select sum(b.resource_length) from ex_course_chapter_period a
inner join ex_resource b on a.resource_id=b.id
where a.course_id=#{courseId}
select count(1) from (select student_id,count(1) as study_count from ex_student_study where phase_id=#{phaseId} group by student_id) as a
where a.study_count=(select count(1) as period_count from ex_course_chapter_period where course_id=#{courseId})