ORA-00937: not a single-group group function说明及解决方法(E文)

ORA-00937: not a single-group group function说明及解决方法(E文)

转载  2009年03月15日 21:17:00
  • 21110

 A SELECT list cannot include both a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, and an individual column expression, unless the individual column expression is included in a GROUP BY clause.



Drop either the group function or the individual column expression from the SELECT list or add a GROUP BY clause that includes all individual column expressions listed.


eg:

SQL> select owner, count(*)
  2  from dba_segments;
select owner, count(*)
       *
ERROR at line 1:
ORA-00937: not a single-group group function

Because we have a group function (COUNT) in our column list, and an additional column (OWNER), we have to include the GROUP BY clause in our select statement.


SQL> select owner, count(*)
  
2  from dba_segments
  3  group by owner;

OWNER                            COUNT(*)
------------------------------ ----------
USER1                              166
USER2                              166

 
  • mqj1746102202
    2016-07-17 16:333楼
  • select s.course_id , "MAX"(count(*)) from SC s GROUP BY s.course_id
    在这种情况下也会出现上面的错误提示信息,咋办?
  • 回复
  • yeliankeng
    2014-05-30 10:472楼
  • 感谢~~
  • 回复
  • amu1111
    2010-07-19 16:391楼
  • good,thank you!!

你可能感兴趣的:(Oracle)