<?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.web.mapper.ZdInfoMapper">
    
    <resultMap type="ZdInfo" id="ZdInfoResult">
        <result property="id"    column="id"    />
        <result property="money"    column="money"    />
        <result property="zdrq"    column="zdrq"    />
    </resultMap>

    <sql id="Base_Column_List">
        id,
        money,
        zdrq
    </sql>

    <select id="selectHdZdList" resultType="HdZdDTO">
        select
            id,
            round(COALESCE(total_cost / case when (select count(*) from hd_qd where fid = info.id) = 0 then null else (select count(*) from hd_qd where fid = info.id) end,0),2) money
        from hd_info info
        where total_cost is not null and id not in (select hd_id from hd_zd group by hd_id)
    </select>

</mapper>