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,

解决方案 »

  1.   

    group by 要加入字段  projectmai0_.project_Name 
      

  2.   

    group by  列出在select 后未使用聚会函数的列
      

  3.   

    group by 加上这个啊projectmai0_.project_Name 
      

  4.   

    group by col_2_0_ 
      

  5.   

    楼主在select语句中,除了聚合函数外,还有PROJECTMAI0_.PROJECT_NAME。所以,group by 应该依据此列才行,修改为group by PROJECTMAI0_.PROJECT_NAME。
      

  6.   

    你这sql语句分组查询出的结果,在select中只能含分组的字段与聚合函数,不能含单行函数的字段