【发布时间】:2010-09-28 11:56:20
【问题描述】:
我正在努力实现这一目标
select
case
when Org_CD = '1111' or Org_CD in (select distinct New_Org_CD from #temp) then 'International'
end as 'Organisation',
count(*)
from #AnotherTempTable
group by
case
when Org_CD = '1111' or Org_CD in (select distinct New_Org_CD from #temp) then 'International'
end
我收到了这个错误:
列“#AnotherTempTable.Org_Cd”是 在选择列表中无效,因为它 不包含在任何一个 聚合函数或 GROUP BY 子句。
是因为我不能在 case 语句中使用“in”关键字吗?如果是的话,任何已知的解决方法都会很有帮助!
【问题讨论】:
-
你想在这里做什么?这对我来说真的没有意义......
-
所有要做的就是提供一个单独的列,其中包含存在于 #temp 或 1111 中的每个
org_cd的“组织”。 -
我刚刚用 count() 更新了它。我试图获取与 1111 或其他组织代码匹配的组织的计数()。