Hi folks,
I'm trying to write a query with an IIF statement that displays service names.
SELECT IIf([TestTable].[Svc_SubAcct]=9,[Testtable].[Svc_ComName],[Testtable].[Svc_SubAcct]) AS Service, Count(IIf([TestTable].[Svc_SubAcct]=9,[Testtable].[Svc_ComName],[Testtable].[Svc_SubAcct])) AS [Count], TestTable.CompanyID, TestTable.InvTypeID, TestTable.InvPeriod
FROM TestTable
GROUP BY IIf([TestTable].[Svc_SubAcct]=9,[Testtable].[Svc_ComName],[Testtable].[Svc_SubAcct]), TestTable.CompanyID, TestTable.InvTypeID, TestTable.InvPeriod;
Problem:
Testtable.Svc_SubAcct is a combobox/lookup field
[Testtable].[Svc_ComName] is a combobox/lookup field
The query is displaying the number column vs. the text column that I want it to display
I know in vba I can refer to the column using .column(#)
But that doesn't seem to work in SQL.
ANy ideas?