我正在执行以下请求,并收到“ORA-00979:不是 GROUP BY 表达式”错误。
select distinct
field1,
field2,
field3,
count(*) as field4,
field5,
field6,
case
when smt1>0 then 'Deleted'
when smt2>0 then 'Impacted'
when smt3>0 then 'Unknown'
else 'Clean'
end as field7,
field8,
field9,
field10,
field11,
field12,
field13
from (<here a big sub query>) A
group by field1, field2
order by field1, field2
我知道我必须将 SELECT 的所有列放在 GROUP BY 语句中,除了分组函数(如 MAX 或 SUM),所以我正在尝试以下查询,但我收到相同的错误消息:
select distinct
field1,
field2,
field3,
count(*) as field4,
field5,
field6,
case
when smt1>0 then 'Deleted'
when smt2>0 then 'Impacted'
when smt3>0 then 'Unknown'
else 'Clean'
end as field7,
field8,
field9,
field10,
field11,
field12,
field13
from (<here a big sub query>) A
group by field1, field2, field3, field5, field6, field8, field9, field10, field11, field12, field13
order by field1, field2
如何在不改变查询的整体含义的情况下解决这个问题?
非常感谢你,马丁