ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORA-00937: not a single-group group function

ORA-00937: not a single-group group function

原创 Linux操作系统 作者:-Nero- 时间:2010-03-25 14:53:24 0 删除 编辑

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


 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23184238/viewspace-630395/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: group by 子句
请登录后发表评论 登录
全部评论

注册时间:2010-01-14

  • 博文量
    16
  • 访问量
    33114