我試圖做到這一點有「___中(選擇不同___從#TEMP)」萬一聲明
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
我收到此錯誤:
Column '#AnotherTempTable.Org_Cd' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
是不是因爲我不能在case語句中使用「in」關鍵字?如果是的話,任何已知的解決方法都會更有幫助!
你想在這裏做什麼?這對我來說並沒有什麼意義...... – 2010-09-24 00:49:15
所有要做的事情是提供一個列,其中包含每個org_cd的「組織」,它存在於#temp或1111中。 – 2010-09-24 00:54:06
我剛更新了它計數(*)。我試圖爲那些匹配1111或其他組織代碼的組織計數(*)。 – Jason 2010-09-24 03:23:20