SUM(case when user.state > 0 then 1 else 0 end)AS test,
SUM(case when user.state = 2 then 1 else 0 end)AS pass,
ROUND(SUM(case when user.state = 2 then 1 else 0 end)/COUNT(user.user_course_id)*100)AS rate
FROM
t_train_course course
INNER JOIN t_train_user_course user ON course.course_id = user.course_id
where course.status = '1' AND course.is_del = '0' AND user.is_del = '0'
<where>
<iftest="courseName != null and courseName != ''"> and c.course_name like concat('%', #{courseName}, '%')</if>
<iftest="dataKind != null and dataKind != ''"> and data_kind = #{dataKind}</if>
<iftest="releaseTimeBegin != null and releaseTimeBegin != '' and releaseTimeEnd != null and releaseTimeEnd != ''"> and release_time BETWEEN #{releaseTimeBegin} AND #{releaseTimeEnd}</if>