<?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.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatEventOrgDPOMapper">

    <select id="selectMlist" resultType="com.njcn.prepare.harmonic.pojo.po.RStatEventOrgDVO">
        SELECT org_no                                 "orgNo",
               event_type                             "eventType",
               round(avg(event_measurement), 2)       "emAvg",
               sum(event_measurement)       "emSum",
               sum(event_count)                       "ecSum",
               round(avg(event_measurement_ratio), 2) "emrAvg"
        FROM r_stat_event_org_d
        WHERE date_format(data_date, '%y%m%d') &gt;= date_format(#{startTime}, '%y%m%d')
          AND date_format(data_date, '%y%m%d') &lt;= date_format(#{endTime}, '%y%m%d')
          AND org_no = #{orgId}
          AND data_type = #{dataTypeId}
        GROUP BY org_no,
                 event_type
    </select>


    <select id="selectQlist" resultType="com.njcn.prepare.harmonic.pojo.po.RStatEventOrgDVO">
        SELECT
               org_no                                 "orgNo",
               event_type                             "eventType",
               sum(event_measurement)       "emSum",
               sum(event_count)                       "ecSum"
        FROM r_stat_event_org_d
        WHERE date_format(data_date, '%y%m%d') &gt;= date_format(#{startTime}, '%y%m%d')
          AND date_format(data_date, '%y%m%d') &lt;= date_format(#{endTime}, '%y%m%d')
          AND org_no = #{orgId}
          AND data_type = #{dataTypeId}
        GROUP BY org_no,
                 event_type
    </select>

</mapper>