Oracle ORA-00979-“不是GROUP BY表达式" [英] Oracle ORA-00979 - "not a GROUP BY expression"

查看:106
本文介绍了Oracle ORA-00979-“不是GROUP BY表达式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我这个特殊的查询吗?尝试运行此命令时出现ORA-00979:

Can anybody please help me with this particular query? I'm having ORA-00979 when trying to run this:

select   t0.title, count (1) as count0, (select   count (1)
      from contract c1, se se1
      where c1.c_id = se1.c_id
      and se1.svc_id = 3
      and se1.deleted = 0
      and c1.deleted = 0
      and c1.c_date between to_date ('07.10.2000', 'dd.mm.yyyy') 
                        and to_date ('22.11.2010', 'dd.mm.yyyy')
      and c1.company = 0
      and c1.tdata.tariff = c0.tdata.tariff
    ) as count1
  from contract c0, se se0, tariff t0
  where c0.c_id = se0.c_id
  and se0.svc_id = 3
  and se0.deleted = 0
  and c0.deleted = 0
  and c0.c_date between to_date ('21.11.2000', 'dd.mm.yyyy') 
                and to_date ('06.01.2011', 'dd.mm.yyyy')
  and c0.company = 0
  and t0.tariff_id = c0.tdata.tariff
  group by t0.title

推荐答案

问题是您的带有select count(1)部分的子查询.仅仅因为其中包含了一个计数,实际上并不能使它成为一个汇总.它仍然是将应用于每一行的子查询,您可以看到它使用的值c0.tdata.tariff不在组中.

The problem is your subquery with the select count(1) part. Just because it's got a count in it doesn't actually make it an aggregate. It's still a subquery that will be applied to every row and as you can see it uses the value c0.tdata.tariff which is not part of the group.

这篇关于Oracle ORA-00979-“不是GROUP BY表达式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆