当前位置: 代码迷 >> Oracle管理 >> ORA-00979: not a GROUP BY expression解决方案
  详细解决方案

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

热度:81   发布时间:2016-04-24 04:52:38.0
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。
  相关解决方案