因为该列没有包含在聚合函数或 GROUP BY 子句中。 啥意思??

lijing3333 2011-06-10 07:46:25
select a.Accounts,(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount from QPGameUserDB.dbo.AccountsInfo as a inner join QPTreasureDB.dbo.GameScoreInfo as b on a.UserID=b.UserID


错误信息:无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。

这个什么原因啊 报这个错 是啥意思 没怎么懂
...全文
523 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunshinebean 2011-11-03
  • 打赏
  • 举报
回复
看看2L怎么写的
wujianfeng32 2011-06-10
  • 打赏
  • 举报
回复
哥服了you
chuanzhang5687 2011-06-10
  • 打赏
  • 举报
回复
sql语句后面加个group by a.Accounts
--小F-- 2011-06-10
  • 打赏
  • 举报
回复
select
a.Accounts,(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount
from
QPGameUserDB.dbo.AccountsInfo as a
inner join
QPTreasureDB.dbo.GameScoreInfo as b
on
a.UserID=b.UserID group by a.Accounts
叶子 2011-06-10
  • 打赏
  • 举报
回复
--两种解决方式:
--1、
select a.Accounts,(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount from QPGameUserDB.dbo.AccountsInfo as a inner join QPTreasureDB.dbo.GameScoreInfo as b on a.UserID=b.UserID group by a.Accounts
--2、
select min(a.Accounts),(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount from QPGameUserDB.dbo.AccountsInfo as a inner join QPTreasureDB.dbo.GameScoreInfo as b on a.UserID=b.UserID
打一壶酱油 2011-06-10
  • 打赏
  • 举报
回复
select a.Accounts,(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount from QPGameUserDB.dbo.AccountsInfo as a inner join QPTreasureDB.dbo.GameScoreInfo as b on a.UserID=b.UserID
GROUP BY a.Accounts
ForFumm 2011-06-10
  • 打赏
  • 举报
回复
a.Accounts 不唯一, AVG 需要分组求平均


select a.Accounts,(avg(b.WinCount)+avg(b.LostCount)+avg(b.DrawCount)+avg(b.FleeCount)) as GameCount from QPGameUserDB.dbo.AccountsInfo as a inner join QPTreasureDB.dbo.GameScoreInfo as b on a.UserID=b.UserID
GROUP BY a.Accounts

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧