( sum( t.play_length )>= t2.vod_length, 1, 0 ) AS cnt
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.class_id,
t.member_id,
t.vod_id
) t3
) t2 ON t.class_id = t2.class_id
LEFT JOIN (
SELECT
t.id,
count( 1 ) AS total_vods
FROM
class_dict t
LEFT JOIN course_content t2 ON t.course_id = t2.course_id
LEFT JOIN vod_dict t3 ON t2.id = t3.content_id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
AND t.id = #{classId}
) t3 ON t.class_id = t3.id
LEFT JOIN (
SELECT
t2.class_id,
sum(
IF
( t2.cnt >= t4.paper_cnt, 1, 0 )) AS pass_cnt
FROM
(
SELECT
t2.class_id,
t2.member_id,
sum( t2.cnt ) AS cnt
FROM
(
SELECT
t.paper_id,
t.class_id,
t.member_id,
IF
( max( t.score )>= 60, 1, 0 ) AS cnt
FROM
exercise_done_result t
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.paper_id,
t.class_id,
t.member_id
) t2
GROUP BY
t2.class_id,
t2.member_id
) t2
LEFT JOIN class_dict t3 ON t2.class_id = t3.id
LEFT JOIN ( SELECT t.course_id, count( 1 ) AS paper_cnt FROM paper_dict t WHERE t.delete_date IS NULL GROUP BY t.course_id ) t4 ON t3.course_id = t4.course_id
) t4 ON t.class_id = t4.class_id
LEFT JOIN ( SELECT t.class_id, sum( 1 ) AS ask_cnt FROM answering_question t WHERE t.class_id = #{classId} AND t.delete_date IS NULL ) t5 ON t.class_id = t5.class_id
SELECT
t10.mem_cnt AS memberCount,
ifnull( floor( t2.ttl / t10.mem_cnt ), 0 ) AS studyVodCounts,
( sum( t.play_length )>= t2.vod_length, 1, 0 ) AS cnt
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.class_id,
t.member_id,
t.vod_id
) t3
) t2 ON t.class_id = t2.class_id
LEFT JOIN (
SELECT
t.id,
count( 1 ) AS total_vods
FROM
class_dict t
LEFT JOIN course_content t2 ON t.course_id = t2.course_id
LEFT JOIN vod_dict t3 ON t2.id = t3.content_id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
AND t.id = #{classId}
) t3 ON t.class_id = t3.id
LEFT JOIN (
SELECT
t2.class_id,
sum(
IF
( t2.cnt >= t4.paper_cnt, 1, 0 )) AS pass_cnt
FROM
(
SELECT
t2.class_id,
t2.member_id,
sum( t2.cnt ) AS cnt
FROM
(
SELECT
t.paper_id,
t.class_id,
t.member_id,
IF
( max( t.score )>= 60, 1, 0 ) AS cnt
FROM
exercise_done_result t
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.paper_id,
t.class_id,
t.member_id
) t2
GROUP BY
t2.class_id,
t2.member_id
) t2
LEFT JOIN class_dict t3 ON t2.class_id = t3.id
LEFT JOIN ( SELECT t.course_id, count( 1 ) AS paper_cnt FROM paper_dict t WHERE t.delete_date IS NULL GROUP BY t.course_id ) t4 ON t3.course_id = t4.course_id
) t4 ON t.class_id = t4.class_id
LEFT JOIN ( SELECT t.class_id, sum( 1 ) AS ask_cnt FROM answering_question t WHERE t.class_id = #{classId} AND t.delete_date IS NULL ) t5 ON t.class_id = t5.class_id