我正在檢查很多存在的類似錯誤的問題,但無法找到能幫助我解決錯誤的問題 我選擇了案件在接近'then'的情況下指定的非布爾類型的表達式
select
case
when e.EthnCode in ('N','A','B','P','W') then ethnicity
else 'Multi'
end as Ethnicity,
case when cat.CategCode IN ('CH','IN','NB','PG','PP','SR')then Category else 0 end as ' ',
--COUNT (c.EthnCode) as '(A) tottal Numbers of participamts by Rase',
sum(case when C.StatusID =1 or C.StatusID =2 then 1 else 0 end),
sum(case when c.Hispanic then 1 else 0 end) as 'Hisp'
from Ethnicity E
LEFT JOIN Clients C
ON c.EthnCode = e.EthnCode
LEFT join Category cat
ON c.CategCode = cat.CategCode
where c.StatusID = 1
group by case
when e.EthnCode in ('N','A','B','P','W') then ethnicity
else 'Balance Reporting More Than One Race'
end
,並拋出錯誤
Msg 4145, Level 15, State 1, Line 9
An expression of non-boolean type specified in a context where a condition is expected, near 'then'.
9號線
sum(case when c.Hispanic then 1 else 0 end) as 'Hisp'
它強調西班牙 請需要幫助:)
c.Hispanic是什麼類型?當'c.Hispanic'的情況下應該是'case when c.Hispanic = [something]' – climbage 2013-02-25 23:45:46