<?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.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper">

    <select id="getHealthInfoByArea" resultType="java.util.Map">
        select area                           as area,
               avg(a.avghealthindex) as healthIndex
        from (
                 select avg(health_index) as avghealthindex,
                        area
                 from analysis_data.fan_health_index_day
                 where analysis_obj_type = '片区'
                 group by area
                 union all
                 (
                     select avg(health_index) as avghealthindex,
                            area
                     from analysis_data.pv_health_index_day
                     where analysis_obj_type = '片区'
                     group by area
                 )
             ) a
        group by a.area
    </select>
</mapper>
