您现在的位置是:首页 > 电脑 > 

列在HAVIG子句中无效,因为它不包含在聚合函数或GROUP BY中(column is invalid in the HAVIG clause because it is not contained in either an aggregate function or the GROUP BY)

2025-07-22 01:33:22
列在HAVIG子句中无效,因为它不包含在聚合函数或GROUP BY中(column is invalid in the HAVIG clause because it is not contained in either an aggregate function or the GROUP BY) 我试图使我的列等于过滤器使用,但问题是它给出了此错误消息:
列在HAVIG子句中无效,因为它不包含在聚合函数或GROUP BY中(column is invalid in the HAVIG clause because it is not contained in either an aggregate function or the GROUP BY)

我试图使我的列等于过滤器使用,但问题是它给出了此错误消息:

column is invalid in the HAVIG clause because it is not contained in either an aggregate function or the GROUP BY

当我尝试在select和group中添加过滤器时,它说:

Column names in each view or function must be unique

因为列和过滤器都是相同的:

专栏:

userTable.userid

过滤器:

user_filter.userid

这是我的代码:

SELECT DISTICT userId, username, sum(userItem) from userTable inner join user_filter on userTable.userame = user_filter.userame group by userId, username, having userTable.userId = user_filter.userId

I am trying to make my column equals the filter using having, but the problem is it gives this error message:

column is invalid in the HAVIG clause because it is not contained in either an aggregate function or the GROUP BY

and when I try to add the filter in the select and group by it says that:

Column names in each view or function must be unique

because both the column and the filter are the same:

the Column:

userTable.userid

the Filter:

user_filter.userid

here is my code:

SELECT DISTICT userId, username, sum(userItem) from userTable inner join user_filter on userTable.userame = user_filter.userame group by userId, username, having userTable.userId = user_filter.userId

最满意答案

您不需要Having子句只需在Where子句中添加另一个过滤器

SELECT userid, username, Sum(useritem) FROM usertable IER JOI user_filter O usertable.username = user_filter.username AD usertable.userid = user_filter.userid GROUP BY userid, username

DISTICT也是多余的,因为已经在select使用了Group by

You don't need Having clause just add another filter in Where clause

SELECT userid, username, Sum(useritem) FROM usertable IER JOI user_filter O usertable.username = user_filter.username AD usertable.userid = user_filter.userid GROUP BY userid, username

Also DISTICT is redundant because already Group by is used in select

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/654079.html

相关标签:无
上传时间: 2023-07-28 12:53:26
留言与评论(共有 5 条评论)
本站网友 产权证号
9分钟前 发表
username
本站网友 彻思叔叔加盟
22分钟前 发表
username
本站网友 非洲大草原上的动物
15分钟前 发表
username
本站网友 红海洋
28分钟前 发表
Column names in each view or function must be unique because both the column and the filter are the same