<?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="uml.tech.bigdata.njMapper.FarmWorkNjMapper">

    <select id="selectTotalStatus" resultType="uml.tech.bigdata.bean.FarmWork">
        SELECT did, sum(jobArea) jobArea, sum(if(absoluteJobTime is null, jobTime, absoluteJobTime)) jobTime,
        sum(avgDepth * if(positionsSum is null, jobTime, positionsSum)) totalDepth,
        sum(avgPercentOfPass * if(positionsSum is null, jobTime, positionsSum)) totalPercentOfPass, sum(positionsSum) totalPositionsSum,
        sum(dryingWeight) totalDryingWeight,sum(bundleWeight) totalBundleWeight, sum(bundles) totalBundles, sum(totalDose) totalDose,
        sum(fertilizationTotal) totalFertilization,sum(totalPlotYield) totalPlotYield,sum(jobMileage) totalJobMileage,
        sum(IF(jobMileageType = 0, jobMileage, 0)) totalDidJobMileage  from farm_work
        <where>
<!--            <![CDATA[ jobEndTime > ${startDay} ]]>-->
<!--            and <![CDATA[ jobEndTime < ${endDay} ]]>-->
            jobEndTime &gt; #{startDay}
            and  jobEndTime &lt; #{endDay}
        </where>
        group by did
    </select>
</mapper>
