不是 GROUP BY 表达式
我有以下选择:
Select attribut1, dateattribut, attribut3,
attribut4, attribut15, town_CODE, count(*)
from (
select attribut1, dateattribut, attribut3, attribut4, attribut15, (CASE
WHEN TO_CHAR(dateattribut,'YYYY') = '2005' THEN
CASE town_CODE
WHEN '039' THEN '078' WHEN '050' THEN '093'
WHEN '091' THEN '008' WHEN '102' THEN '093'
ELSE town_CODE end
ELSE town_CODE end) as town_CODE
from towntable) GROUP BY attribut1, dateattribut,
attribut3, attribut4,
attribut15, town_CODE
having count(*) > 1;
当我在我们的服务器上执行此查询时,它工作正常。但在我客户的服务器上,我收到oracle错误ORA-00979:不是GROUP BY表达式
。
到目前为止,我发现我的案例和别名有问题。 没有这个它就可以工作。
有什么建议吗?
*我试图用这个语句做的是获取所有复式条目。通过内部查询,我将所有旧代码更改为新代码,然后我想将它们分组以查看它们是否存在多次。 有些客户确实使用了旧代码,现在他们可能两次使用同一个城镇。
编辑
SELECT * FROM Product_Component_version
,我得到了两个:
Product Version Status
NLSRTL 10.2.0.4.0 Production
Oracle Database 10g Enterprise Edition 10.2.0.4.0 64bi
PL/SQL 10.2.0.4.0 Production
TNS for 64-bit Windows: 10.2.0.4.0 Production
edit2
我的测试表明他不喜欢使用别名调用。 是否有一个设置无法识别别名?
i've following select:
Select attribut1, dateattribut, attribut3,
attribut4, attribut15, town_CODE, count(*)
from (
select attribut1, dateattribut, attribut3, attribut4, attribut15, (CASE
WHEN TO_CHAR(dateattribut,'YYYY') = '2005' THEN
CASE town_CODE
WHEN '039' THEN '078' WHEN '050' THEN '093'
WHEN '091' THEN '008' WHEN '102' THEN '093'
ELSE town_CODE end
ELSE town_CODE end) as town_CODE
from towntable) GROUP BY attribut1, dateattribut,
attribut3, attribut4,
attribut15, town_CODE
having count(*) > 1;
when i execute this query on our server it work fine. but on the server of my customer i get the oracle error ORA-00979: not a GROUP BY expression
.
As far i found out that im having problems with the Case's and with the alias.
with out this it works.
any suggestions?
*what i'm trying to do with this statement is to get all double entry's. with the inner query i change all old codes to the new one, and then i want to group them to see if they exists multiply times.
Some customers did used old codes and now its possible that they have the same town 2 times.
edit
SELECT * FROM product_component_version
and i get on both:
Product Version Status
NLSRTL 10.2.0.4.0 Production
Oracle Database 10g Enterprise Edition 10.2.0.4.0 64bi
PL/SQL 10.2.0.4.0 Production
TNS for 64-bit Windows: 10.2.0.4.0 Production
edit2
my test showed me that he doesn't like calling with the alias.
is there a setting, that alias are not recognized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这意味着以下两种情况之一:
似乎很可能,因为您在此处发布的代码显然不是您在自己的服务器上运行的代码。已经指出,它包含一些语法错误,尽管两者都不会事实上,
该错误意味着您在投影中有一个非聚合列,该列不在 GROUP BY 子句中,或者您在 GROUP BY 子句中有某些内容不在投影中。
This means one of two things:
The latter seems quite likely, as the code you posted here obviously isn't the code you run on your own server. As others have pointed out, it contains a couple of syntax errors although neither would in fact hurl ORA-00979.
That error means you have a non-aggregate column in the projection which isn't in the GROUP BY clause or perhaps you have something in the GROUP BY clause which isn't in the projection.
表名后面缺少括号,attribut15 后面缺少逗号。试试这个:
You are missing a bracket after the table name plus a comma after attribut15. Try this:
原始查询中似乎存在一两个语法错误 - 以下内容应该有效:
There appear to be one or two syntax errors in the original query - the following should work:
我的解决方案是使用视图。
内部选择为视图,然后外部正常选择,效果很好。
我发现他不喜欢外部选择中的town_CODE。
My solution is to use an View.
Inner Select as View and then the outer select as normal, and it works fine.
i found out that he doesn't like town_CODE in the outer select.