表连接问题

killed1988 2008-07-17 09:44:59
select a.m_Subject,a.m_TrainingExpense,a.m_ID,a.m_OpenType,
a.m_PlanStartTime,a.m_DuringTime,a.m_MaxAmount,a.m_Description,
count(b.att_AttendUserID) as currcount
from met_meeting as a inner join Met_Attendees as b
on a.m_id = b.m_id
where a.m_id='100010000006726' and b.att_IsAttend = 1



提示错误:
消息 8120,级别 16,状态 1,第 1 行
选择列表中的列 'met_meeting.m_Subject' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。


什么愿意导致的?? 谢谢
...全文
48 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 grearo 的回复:]
SQL codeselect a.m_Subject,a.m_TrainingExpense,a.m_ID,a.m_OpenType,
a.m_PlanStartTime,a.m_DuringTime,a.m_MaxAmount,a.m_Description,
count(b.att_AttendUserID) as currcount
from met_meeting as a inner join Met_Attendees as b
on a.m_id = b.m_id
where a.m_id='100010000006726' and b.att_IsAttend = 1
group by m_Subject ,m_TrainingExpense,m_ID,m_OpenType,m_PlanStartTime,m_DuringTime,m_MaxAmount,…
[/Quote]


非常好
grearo 2008-07-17
  • 打赏
  • 举报
回复
select a.m_Subject,a.m_TrainingExpense,a.m_ID,a.m_OpenType,
a.m_PlanStartTime,a.m_DuringTime,a.m_MaxAmount,a.m_Description,
count(b.att_AttendUserID) as currcount
from met_meeting as a inner join Met_Attendees as b
on a.m_id = b.m_id
where a.m_id='100010000006726' and b.att_IsAttend = 1
group by m_Subject ,m_TrainingExpense,m_ID,m_OpenType,m_PlanStartTime,m_DuringTime,m_MaxAmount,m_Description
tengjian1981 2008-07-17
  • 打赏
  • 举报
回复
select a.m_Subject,a.m_TrainingExpense,a.m_ID,a.m_OpenType,
a.m_PlanStartTime,a.m_DuringTime,a.m_MaxAmount,a.m_Description,
(select count(b.att_AttendUserID)
from met_meeting as a inner join Met_Attendees as b
on a.m_id = b.m_id
where a.m_id='100010000006726' and b.att_IsAttend = 1) as currcount
from met_meeting as a inner join Met_Attendees as b
on a.m_id = b.m_id
where a.m_id='100010000006726' and b.att_IsAttend = 1
  • 打赏
  • 举报
回复
一、 b.m_id 必须出现在select 跟 from 之间 因为b.m_id没有被聚合函数修饰,

二、要吗你去掉后面的where以后的语句(包括where)

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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