<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.koobietech.eas.dao.mapper.LessonMapper">

    <select id="getTeacherboard" resultType="com.koobietech.eas.dao.pojo.LessonPojo" >
        SELECT

        ( SELECT COUNT(*) AS alltotal FROM eas_edu_schedule WHERE teacher_id = #{uid} ) AS alltotal,

        ( SELECT COUNT(*) AS pending  FROM eas_edu_schedule  WHERE teacher_id = #{uid}  AND start_time &gt; NOW()
        AND end_time &lt; DATE_FORMAT( CURDATE() + INTERVAL ( 24-1 ) HOUR, '%Y-%m-%d 23:59:59' )
        ) AS pending,

        ( SELECT count(*) AS attendance  FROM eas_arc_tls_attendance  WHERE schedule_id IN
        ( SELECT id FROM eas_edu_schedule WHERE teacher_id = #{uid} AND end_time &lt; NOW() )  AND ( ISNULL( `month` ) OR ISNULL( `afternoon` ) )
        ) AS attendance

    </select>

    <select id="getStudentboard" resultType="com.koobietech.eas.dao.pojo.LessonPojo" >
        SELECT

            ( SELECT COUNT(*) AS alltotal FROM eas_edu_schedule ) AS alltotal,

            ( SELECT COUNT(*) AS pending  FROM eas_edu_schedule  WHERE start_time &gt; NOW()
                   AND end_time &lt; DATE_FORMAT( CURDATE() + INTERVAL ( 24-1 ) HOUR, '%Y-%m-%d 23:59:59' )
            ) AS pending,

            ( SELECT count(*) AS attendance  FROM eas_arc_tls_attendance  WHERE schedule_id IN
                 ( SELECT id FROM eas_edu_schedule WHERE end_time &lt; NOW() )  AND ( ISNULL( `month` ) OR ISNULL( `afternoon` ) )
            ) AS attendance
    </select>

    <select id="getAllboard" resultType="com.koobietech.eas.dao.pojo.LessonPojo" >
        SELECT
        ( SELECT COUNT(*) AS alltotal FROM eas_edu_schedule WHERE class_id IN (
        SELECT class_id FROM eas_edu_clt_relation WHERE student_id = #{uid}
        ) ) AS alltotal,

        ( SELECT COUNT(*) AS pending  FROM eas_edu_schedule  WHERE class_id IN (
        SELECT class_id FROM eas_edu_clt_relation WHERE student_id = #{uid}
        ) AND start_time &gt; NOW()
        AND end_time &lt; DATE_FORMAT( CURDATE() + INTERVAL ( 24-1 ) HOUR, '%Y-%m-%d 23:59:59' )
        ) AS pending,

        ( SELECT count(*) AS attendance  FROM eas_arc_tls_attendance  WHERE schedule_id IN
        ( SELECT id FROM eas_edu_schedule WHERE class_id IN (
        SELECT class_id FROM eas_edu_clt_relation WHERE student_id = #{uid}
        ) AND end_time &lt; NOW() )  AND ( ISNULL( `month` ) OR ISNULL( `afternoon` ) )
        ) AS attendance
    </select>
</mapper>