ORA-00979 not a group by expression

后端 未结 8 1801
梦谈多话
梦谈多话 2020-11-21 04:33

I am getting ORA-00979 with the following query:

SELECT cr.review_sk, cr.cs_sk, cr.full_name,
tolist(to_char(cf.fact_date, \'mm/dd/yyyy\')) \"appt\",
cs.cs_i         


        
8条回答
  •  自闭症患者
    2020-11-21 04:41

    You must put all columns of the SELECT in the GROUP BY or use functions on them which compress the results to a single value (like MIN, MAX or SUM).

    A simple example to understand why this happens: Imagine you have a database like this:

    FOO BAR
    0   A
    0   B
    

    and you run SELECT * FROM table GROUP BY foo. This means the database must return a single row as result with the first column 0 to fulfill the GROUP BY but there are now two values of bar to chose from. Which result would you expect - A or B? Or should the database return more than one row, violating the contract of GROUP BY?

提交回复
热议问题