select **C.ITEM_NAME**,
**Y.PLAN_YEAR**,
SUM(X.GAS_CONS_SCALE)GAS_CONS_SCALE,
SUM(X.CY_DRILL_NUM)CY_DRILL_NUM ,
SUM(X.BY_DRILL_NUM)BY_DRILL_NUM,
SUM(X.CY_END_DRILL_NUM)CY_END_DRILL_NUM,
SUM(X.BY_END_DRILL_NUM)BY_END_DRILL_NUM,
SUM(X.CY_FOOTAGE)CY_FOOTAGE,
SUM(X.BY_FOOTAGE)BY_FOOTAGE,
SUM(X.CY_END_TEST_OIL)CY_END_TEST_OIL,
SUM(X.BY_END_TEST_OIL)BY_END_TEST_OIL,
SUM(X.CY_INDUSTRY_WELL)CY_INDUSTRY_WELL,
SUM(X.BY_INDUSTRY_WELL)BY_INDUSTRY_WELL,
X.REMARKS
from PRODUCTION.CD_ITEM C
LEFT JOIN PRODUCTION.PC_PLAN_ITEM M ON C.ITEM_ID=M.ITEM_ID
LEFT JOIN PRODUCTION.PC_YEAR_PLAN Y ON Y.YEAR_PLAN_ID=M.YEAR_PLAN_ID
LEFT JOIN PRODUCTION.PC_PRODUCTIVITY_PLAN_INDEX X ON X.ITEM_ID=C.ITEM_ID
WHERE C.ITEM_CLASS='2008' AND Y.PLAN_TYPE='2'
<if test="planYear !=null and planYear !=''">
AND PLAN_YEAR=#{planYear,jdbcType=VARCHAR}
</if>
GROUP BY **C.ITEM_NAME**,C.ITEM_YEAR,**Y.PLAN_YEAR**,X.REMARKS ORDER BY C.ITEM_NAME
但凡Oracle 中有 group by 则在 所出现字段必须全部出现在group by 后面(除聚合函数外sum,avg等),注意