<?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.huimv.modular.eartagdata.mapper.EartagDataMapper">

    <select id="countByTime" resultType="com.huimv.modular.collectorregister.EartagDataCountVo">
         SELECT
          DATE_FORMAT(`time`,"%y-%m-%d %H") count_time,COUNT(*) upload_count, CAST(AVG(env_temp) AS DECIMAL(10,2)) envTemp
	        FROM `eartag_data`
	        ${ew.customSqlSegment}
    </select>



    <select id="countByDay" resultType="com.huimv.modular.collectorregister.EartagDataCountVo">
        SELECT
          DATE_FORMAT(`time`,"%y-%m-%d") count_time,COUNT(*) upload_count, CAST(AVG(env_temp) AS DECIMAL(10,2)) envTemp
	        FROM `eartag_data`
	        ${ew.customSqlSegment}
    </select>


    <select id="countByDay" resultType="com.huimv.modular.collectorregister.EartagDataCountVo">
        SELECT
          DATE_FORMAT(`time`,"%y-%m-%d") count_time,COUNT(*) upload_count, CAST(AVG(env_temp) AS DECIMAL(10,2)) envTemp
	        FROM `eartag_data`
	        ${ew.customSqlSegment}
    </select>


    <select id="findByCondition" resultType="com.huimv.modular.eartagdata.entity.EartagData">
        SELECT * FROM eartag_data ed1 JOIN (SELECT MAX(id) id FROM eartag_data ed2 ${ew.customSqlSegment}) b ON ed1.id = b.id
    </select>





</mapper>
