<?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="cn.com.victorysoft.business.calc.dao.IndexDao">

  <select id="selectUnitDaily" parameterType="UnitDateParam" resultType="UnitDaily">
    select
    count(1) totalWell,
    nvl(sum(case when scsj > 0 then 1 end), 0) openWell,
    nvl(sum(case when sit.zsgy = '单注' then 1 end), 0) singleWell,
    nvl(sum(case when sit.zsgy = '分注' then 1 end), 0) splitWell,
    nvl(sum(t.rzsl), 0) dailyWater
    from ys_dba02 t
    left join sys_inject_technology sit
    on t.zsfs = sit.dm
    where rq = #{testdate}
    and dwdm in (select unitcode
    from SYS_UNITINFO
    start with UNITCODE = #{unitcode}
    connect by prior UNITCODE = P_UNITCODE)
  </select>

</mapper>