Error: Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause)

前端 未结 3 1049
花落未央
花落未央 2020-12-21 18:02

I am using Firebird SQL. The below mentioned query returns 4 rows as shown in the figure.

    SELECT a.EPS_ID,b.C_NAME,c.AY_YR_NAME,d.S_NAME,e.E_NAME
FROM 
          


        
3条回答
  •  旧巷少年郎
    2020-12-21 18:45

    The usage of GROUP BY makes the engine group the records for you. To do grouping, you have to give advice to the RDBMS for each column, what it should do.

    • Group it? -> Add column to GROUP BY-Clause
    • Not group it? -> ok, what else?
      • ignore the column? remove it from your select-clause
      • Sum it? -> use SUM(mycol)
      • other aggregation functions can be found in the documentation

    Additionally: In your case you try to group by EPS_ID, which is unique in each row. So a grouping by that column will return all rows, because there is nothing to group by. To group records, they have to have the same value.

提交回复
热议问题