<?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.hv.mapper.DHeightValuePatentDetailMapper">

    <select id="queryCompare" resultType="map">
    
    select * from (
     select appli_province
                   , appli_address,year_batch 
                   , appli
                   ,count(*) hv_total 
                   , sum(case when hv_seis_press = '1' then 1 else 0 end)             hv_seis_press
                   , sum(case when hv_keep10_press = '1' then 1 else 0 end)           hv_keep10_press
                   , sum(case when hv_have_overseas_press = '1' then 1 else 0 end)    hv_have_overseas_press
                   , sum(case when hv_high_pledge_press = '1' then 1 else 0 end)      hv_high_pledge_press
                   , sum(case when hv_technology_award_press = '1' then 1 else 0 end) hv_technology_award_press
              from d_height_value_patent_detail where status='10' 
                <if test="year != null  and year != ''">and year_batch = #{year}</if>
              group by appli_province, appli_address, appli ,year_batch 
              ) ff 
    </select>
    <!-- limit #{offset},#{pageSize} -->
    
    <select id="queryCompareCount" resultType="map">
    
    select count(*) C from (
     select appli_province
                   , appli_address,year_batch 
                   , appli
                   ,count(*) hv_total 
                   , sum(case when hv_seis_press = '1' then 1 else 0 end)             hv_seis_press
                   , sum(case when hv_keep10_press = '1' then 1 else 0 end)           hv_keep10_press
                   , sum(case when hv_have_overseas_press = '1' then 1 else 0 end)    hv_have_overseas_press
                   , sum(case when hv_high_pledge_press = '1' then 1 else 0 end)      hv_high_pledge_press
                   , sum(case when hv_technology_award_press = '1' then 1 else 0 end) hv_technology_award_press
              from d_height_value_patent_detail where status='10' 
                <if test="year != null  and year != ''">and year_batch = #{year}</if>
              group by appli_province, appli_address, appli ,year_batch 
              ) ff 
    </select>
    

</mapper>