需要获得平均计数
我想获得客户拥有的产品=A 的平均值。假设 6 个客户的内部选择返回 1,2,1,4,4,4
我希望看到结果为 4,这意味着客户可以拥有的平均产品数量是 4
有人可以确认以下内容吗? 例如
选择 avg(count) 从 ( 选择 count(*) 作为计数 从表1 其中产品 = A 按客户分组) 作为计数
I would like to get average of product=A that a client have. Say inner select return 1,2,1,4,4,4 for 6 clients
I would like to see result as 4 which means the avg product count a client can have is 4
Can somebody please confirm the following.
E.g
Select avg(count)
From (
Select count(*) as count
From Table1
Where product = A
Group by client)
as counts
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
拥有示例数据对于获得帮助很重要。仍然很难确定您的数据外观。假设它看起来像这样:
我无法访问DB2数据库,但是此查询适用于大多数DBMS类型。您可能需要调整以适合DB2。
查询的输出是:
Having sample data is important to getting assistance. It's still difficult to determine how your data looks. Let's assume it looks like this:
I don't have access to a DB2 database, but this query works for most dbms types. You may need to tweak to fit DB2.
Output of query is: