<?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.ruoyi.project.system.mapper.ByClassMapper">

    <resultMap type="ByClass" id="ByClassResult">
        <result property="bjbh" column="bjbh"/>
        <result property="deptId" column="dept_id"/>
        <result property="bjtype" column="bjtype"/>
        <result property="bhxh" column="bhxh"/>
        <result property="xn" column="xn"/>
        <result property="bjmc" column="bjmc"/>
        <result property="bjrych" column="bjrych"/>
        <result property="jbny" column="jbny"/>
        <result property="zbjs" column="zbjs"/>
        <result property="zbjsxm" column="zbjsxm"/>
        <result property="pbjs" column="pbjs"/>
        <result property="pbjsxm" column="pbjsxm"/>
        <result property="zljs" column="zljs"/>
        <result property="zljsxm" column="zljsxm"/>
        <result property="childcount" column="childcount"/>
        <result property="childcheckincount" column="childcheckincount"/>
        <result property="isdel" column="isdel"/>
        <result property="createtime" column="createtime"/>
        <result property="month" column="month"/>
        <result property="day1" column="day1"/>
        <result property="day2" column="day2"/>
        <result property="day3" column="day3"/>
        <result property="day4" column="day4"/>
        <result property="day5" column="day5"/>
        <result property="day6" column="day6"/>
        <result property="day7" column="day7"/>
        <result property="day8" column="day8"/>
        <result property="day9" column="day9"/>
        <result property="day10" column="day10"/>
        <result property="day11" column="day11"/>
        <result property="day12" column="day12"/>
        <result property="day13" column="day13"/>
        <result property="day14" column="day14"/>
        <result property="day15" column="day15"/>
        <result property="day16" column="day16"/>
        <result property="day17" column="day17"/>
        <result property="day18" column="day18"/>
        <result property="day19" column="day19"/>
        <result property="day20" column="day20"/>
        <result property="day21" column="day21"/>
        <result property="day22" column="day22"/>
        <result property="day23" column="day23"/>
        <result property="day24" column="day24"/>
        <result property="day25" column="day25"/>
        <result property="day26" column="day26"/>
        <result property="day27" column="day27"/>
        <result property="day28" column="day28"/>
        <result property="day29" column="day29"/>
        <result property="day30" column="day30"/>
        <result property="day31" column="day31"/>

    </resultMap>

    <sql id="selectByClassVo">
        select bjbh, dept_id, bjtype, bhxh, xn, bjmc, bjrych, jbny,
        zbjs, (select nick_name from sys_user where sys_user.user_id=zbjs) zbjsxm,
        pbjs, (select nick_name from sys_user where sys_user.user_id=pbjs) pbjsxm,
        zljs, (select nick_name from sys_user where sys_user.user_id=zljs) zljsxm,
        (select count(*) from by_child WHERE by_child.classid=d.bjbh) childcount,
        (select count(*) from by_child_checkin_detail WHERE by_child_checkin_detail.classid=d.bjbh and type='01' and date_format(by_child_checkin_detail.create_time,'%Y-%m-%d')=date_format(sysdate(),'%Y-%m-%d')) childcheckincount,
        isdel, createtime from by_class d
    </sql>

    <select id="selectByClassList" parameterType="ByClass" resultMap="ByClassResult">
        <include refid="selectByClassVo"/>
        where isdel='0'
        <if test="bjbh != null  and bjbh != ''">and bjbh = #{bjbh}</if>
        <if test="deptId != null  and deptId != ''">and dept_id = #{deptId}</if>
        <if test="bjtype != null  and bjtype != ''">and bjtype = #{bjtype}</if>
        <if test="bhxh != null ">and bhxh = #{bhxh}</if>
        <if test="xn != null  and xn != ''">and xn = #{xn}</if>
        <if test="bjmc != null  and bjmc != ''">and bjmc like concat('%', #{bjmc}, '%')</if>
        <if test="bjrych != null  and bjrych != ''">and bjrych = #{bjrych}</if>
        <if test="jbny != null ">and jbny = #{jbny}</if>
        <if test="zbjs != null ">and zbjs = #{zbjs}</if>
        <if test="pbjs != null ">and pbjs = #{pbjs}</if>
        <if test="zljs != null ">and zljs = #{zljs}</if>
        <if test="zbjsxm != null and zbjsxm != ''">and zbjsxm like concat('%', #{zbjsxm}, '%')</if>
        <if test="pbjsxm != null and pbjsxm != ''">and pbjsxm like concat('%', #{pbjsxm}, '%')</if>
        <if test="zljsxm != null and zljsxm != ''">and zljsxm like concat('%', #{zljsxm}, '%')</if>
        <if test="isdel != null  and isdel != ''">and isdel = #{isdel}</if>
        <if test="createtime != null ">and createtime = #{createtime}</if>
        <!-- 数据范围过滤 -->
        ${dataScope}

        order by createtime desc
    </select>

    <select id="selectByClassById" parameterType="String" resultMap="ByClassResult">
        <include refid="selectByClassVo"/>
        where bjbh = #{bjbh}
    </select>

    <!--<select id="selectByClassByUserId" parameterType="ByClass" resultMap="ByClassResult">-->
    <!--<include refid="selectByClassVo"/>-->
    <!--<where>-->
    <!--<if test="zbjs != null ">or zbjs = #{zbjs}</if>-->
    <!--<if test="pbjs != null ">or pbjs = #{pbjs}</if>-->
    <!--<if test="zljs != null ">or zljs = #{zljs}</if>-->
    <!--and isdel = 0-->
    <!--</where>-->
    <!--&lt;!&ndash; 数据范围过滤 &ndash;&gt;-->
    <!--${dataScope}-->
    <!--</select>-->

    <select id="selectByClassByUserId" parameterType="ByClass" resultMap="ByClassResult">
        <include refid="selectByClassVo"/>
        where
        (zbjs = #{zbjs}
        or pbjs = #{pbjs}
        or zljs = #{zljs}
        )
        and isdel = 0
        <!-- 数据范围过滤 -->
        ${dataScope}
    </select>

    <insert id="insertByClass" parameterType="ByClass">
        insert into by_class
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bjbh != null  and bjbh != ''">bjbh,</if>
            <if test="deptId != null  and deptId != ''">dept_id,</if>
            <if test="bjtype != null  and bjtype != ''">bjtype,</if>
            <if test="bhxh != null ">bhxh,</if>
            <if test="xn != null  and xn != ''">xn,</if>
            <if test="bjmc != null  and bjmc != ''">bjmc,</if>
            <if test="bjrych != null  and bjrych != ''">bjrych,</if>
            <if test="jbny != null ">jbny,</if>
            <if test="zbjs != null ">zbjs,</if>
            <if test="pbjs != null ">pbjs,</if>
            <if test="zljs != null ">zljs,</if>
            <if test="isdel != null  and isdel != ''">isdel,</if>
            <if test="createtime != null ">createtime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bjbh != null  and bjbh != ''">#{bjbh},</if>
            <if test="deptId != null  and deptId != ''">#{deptId},</if>
            <if test="bjtype != null  and bjtype != ''">#{bjtype},</if>
            <if test="bhxh != null ">#{bhxh},</if>
            <if test="xn != null  and xn != ''">#{xn},</if>
            <if test="bjmc != null  and bjmc != ''">#{bjmc},</if>
            <if test="bjrych != null  and bjrych != ''">#{bjrych},</if>
            <if test="jbny != null ">#{jbny},</if>
            <if test="zbjs != null ">#{zbjs},</if>
            <if test="pbjs != null ">#{pbjs},</if>
            <if test="zljs != null ">#{zljs},</if>
            <if test="isdel != null  and isdel != ''">#{isdel},</if>
            <if test="createtime != null ">#{createtime},</if>
        </trim>
    </insert>

    <update id="updateByClass" parameterType="ByClass">
        update by_class
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null  and deptId != ''">dept_id = #{deptId},</if>
            <if test="bjtype != null  and bjtype != ''">bjtype = #{bjtype},</if>
            <if test="bhxh != null ">bhxh = #{bhxh},</if>
            <if test="xn != null  and xn != ''">xn = #{xn},</if>
            <if test="bjmc != null  and bjmc != ''">bjmc = #{bjmc},</if>
            <if test="bjrych != null  and bjrych != ''">bjrych = #{bjrych},</if>
            <if test="jbny != null ">jbny = #{jbny},</if>
            zbjs = #{zbjs},
            pbjs = #{pbjs},
            zljs = #{zljs},
            <if test="isdel != null  and isdel != ''">isdel = #{isdel},</if>
            <if test="createtime != null ">createtime = #{createtime},</if>
        </trim>
        where bjbh = #{bjbh}
    </update>

    <delete id="deleteByClassById" parameterType="String">
        update by_class set isdel='1'where bjbh = #{bjbh}
    </delete>

    <delete id="deleteByClassByIds" parameterType="String">
        update by_class set isdel='1' where bjbh in
        <foreach item="bjbh" collection="array" open="(" separator="," close=")">
            #{bjbh}
        </foreach>
    </delete>

    <select id="selectststicstSchoolList" parameterType="ByClass"
            resultMap="ByClassResult">
        select d.bjbh,d.dept_id,d.bjmc,
        (select count(*) from by_child where classid=d.bjbh) as childcount,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-01') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day1,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-02') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day2,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-03') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day3,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-04') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day4,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-05') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day5,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-06') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day6,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-07') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day7,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-08') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day8,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-09') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day9,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-10') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day10,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-11') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day11,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-12') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day12,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-13') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day13,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-14') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day14,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-15') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day15,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-16') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day16,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-17') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day17,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-18') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day18,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-19') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day19,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-20') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day20,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-21') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day21,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-22') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day22,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-23') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day23,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-24') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day24,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-25') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day25,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-26') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day26,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-27') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day27,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-28') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day28,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-29') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day29,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-30') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day30,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-31') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day31
        from by_class d
        where d.isdel='0'
        <!-- 数据范围过滤 -->
        ${dataScope}
        union all
        select '','','小计',0,
        round(avg(day1),4),round(avg(day2),4),round(avg(day3),4),round(avg(day4),4),round(avg(day5),4),round(avg(day6),4),round(avg(day7),4),round(avg(day8),4),round(avg(day9),4),round(avg(day10),4),
        round(avg(day11),4),round(avg(day12),4),round(avg(day13),4),round(avg(day14),4),round(avg(day15),4),round(avg(day16),4),round(avg(day17),4),round(avg(day18),4),round(avg(day19),4),round(avg(day20),4),
        round(avg(day21),4),round(avg(day22),4),round(avg(day23),4),round(avg(day24),4),round(avg(day25),4),round(avg(day26),4),round(avg(day27),4),round(avg(day28),4),round(avg(day29),4),round(avg(day30),4),round(avg(day31),4)
        from (
        select d.bjbh,d.dept_id,d.bjmc,
        (select count(*) from by_child where classid=d.bjbh) as childcount,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-01') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day1,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-02') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day2,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-03') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day3,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-04') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day4,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-05') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day5,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-06') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day6,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-07') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day7,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-08') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day8,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-09') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day9,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-10') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day10,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-11') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day11,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-12') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day12,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-13') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day13,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-14') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day14,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-15') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day15,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-16') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day16,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-17') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day17,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-18') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day18,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-19') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day19,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-20') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day20,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-21') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day21,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-22') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day22,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-23') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day23,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-24') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day24,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-25') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day25,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-26') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day26,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-27') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day27,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-28') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day28,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-29') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day29,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-30') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day30,
        ((select count(*) from by_child_checkin_detail where classid=d.bjbh and
        date_format(create_time,'%Y-%m-%d')=concat(#{month},'-31') and type='01')/(select count(*) from by_child where
        classid=d.bjbh)) as day31
        from by_class d
        where d.isdel='0'
        <!-- 数据范围过滤 -->
        ${dataScope}
        ) tmp
    </select>

</mapper>