MyException - 我的异常网
当前位置:我的异常网» Oracle管理 » ORA-00979: not a GROUP BY expression解决方案

ORA-00979: not a GROUP BY expression解决方案

www.MyException.Cn  网友分享于:2013-01-05  浏览:569次
ORA-00979: not a GROUP BY expression
select
            sum(case 
                when placementh1_.house_state='PASS' then 1 
                else 0 
            end) as col_0_0_,
            sum(case 
                when placementh1_.house_state='BACK' then 1 
                else 0 
            end) as col_1_0_,
            projectmai0_.project_Name as col_2_0_ 
        from
            ZCM_PROJECT_MAIN projectmai0_,
            ZCM_PLACEMENT_HOUSE placementh1_,
            ZCM_PLACEMENT_HOUSEINS placementh2_ 
        where
             projectmai0_.project_Status='NOTARRIVE'
            and projectmai0_.project_Id=placementh2_.project_id 
            and placementh2_.house_id=placementh1_.id 
            and projectmai0_.project_Unitid='4028d3f03b64dded013b64fc92450016' 
        group by
            placementh2_.project_id


报错not a GROUP BY expression,
------解决方案--------------------
group by 要加入字段  projectmai0_.project_Name 
------解决方案--------------------
group by  列出在select 后未使用聚会函数的列
------解决方案--------------------
group by 加上这个啊projectmai0_.project_Name 
------解决方案--------------------
楼主在select语句中,除了聚合函数外,还有PROJECTMAI0_.PROJECT_NAME。所以,group by 应该依据此列才行,修改为group by PROJECTMAI0_.PROJECT_NAME。

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有