我有以下代码,我使用 Access DB 生成的,我需要将其转换为 T-SQL,主要是在 IIF 语句上出现错误
SELECT dbo.casyAgeGroups.Sequence, dbo.casyAgeGroups.Description,
Sum(IIf([gender]='Male' And [age]>=[startage] And [age]<=[endage],1,0)) AS Male,
Sum(IIf([gender]='Female' And [age]>=[startage] And [age]<=[endage],1,0)) AS Female
FROM dbo.casyAgeGroups, [qryStats-AgeGenderProfileDetails]
GROUP BY dbo.casyAgeGroups.Sequence,
dbo.casyAgeGroups.Description,
[qryStats-AgeGenderProfileDetails].EntityType
HAVING ((([qryStats-AgeGenderProfileDetails].EntityType)=0));