Oracle mybatis sql group By 字段问题

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等),注意

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值