sql - Oracle ORA-00979 - "not a GROUP BY expression"

标签 sql oracle ora-00979

有人可以帮我解决这个特定的问题吗?我在尝试运行此命令时遇到 ORA-00979:

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 不属于该组。

关于sql - Oracle ORA-00979 - "not a GROUP BY expression",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4605994/

相关文章:

mysql - 将别名设置为数据库表字段中的值

oracle - 从存储过程中检索参数?

sql - 查询适用于 Oracle 10g 但不适用于 11g?

java - 如何运行 Resultset.next() 两次?

用于基于 ARM 的 Debian 设备的 Oracle Instant Client

sql - ORA-00979: 不是一个带有简单示例的 GROUP BY 表达式

sql - 选择 "edit top ' N' 行时更改顺序”

mysql - FIND_IN_SET 或 SELECT * FROM

mysql - select * from table where something 与 select column from table where something