<?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.bonus.boot.manager.index.dao.IndexDao">

    <select id="getAgeDistribution" resultType="java.lang.Integer">
        select count(1)
        from pm_phy_data_info
        where is_active = '1' and phy_sex = '男' AND data_year = #{date} and phy_ole between #{i} and #{j}
    </select>
    <select id="getAgeDistribution2" resultType="java.lang.Integer">
        select count(1)
        from pm_phy_data_info
        where is_active = '1' and phy_sex = '女' and data_year = #{date} and phy_ole between #{i} and #{j}
    </select>
    <select id="getIllnessCount" resultType="com.bonus.boot.manager.index.entity.IndexBean">
        SELECT illness_type, illness_name, COUNT(*) AS total_count
        FROM count_import_message
        WHERE data_year = #{date}
        GROUP BY illness_type , illness_name
        ORDER BY total_count DESC
    </select>
    <select id="getDiseaseDetectionRate" resultType="com.bonus.boot.manager.index.entity.IndexBean">
        SELECT illness_type, illness_name, COUNT(*) AS total_count,
               (SELECT COUNT(DISTINCT name) FROM count_import_message) AS thisNum
        FROM count_import_message
        WHERE data_year = #{date}
        GROUP BY illness_type, illness_name
    </select>
    <select id="getMaleIllnessCount" resultType="com.bonus.boot.manager.index.entity.IndexBean">
        SELECT illness_type, illness_name, COUNT(*) AS total_count
        FROM count_import_message
        WHERE sex = '男' and data_year = #{date}
        GROUP BY illness_type, illness_name
        ORDER BY total_count DESC;
    </select>
    <select id="getFemaleIllnessCount" resultType="com.bonus.boot.manager.index.entity.IndexBean">
        SELECT illness_type, illness_name, COUNT(*) AS total_count
        FROM count_import_message
        WHERE sex = '女' and data_year = #{date} and illness_type != 1
        GROUP BY illness_type, illness_name
        ORDER BY total_count DESC;
    </select>
</mapper>

