codeandcloud
codeandcloud

Reputation: 55200

Error using iif in ms access query

I am trying to fire this query in MS Access

SELECT file_number, 
    IIF(invoice_type='Spent on Coding',SUM(CINT(invoice_amount)), 0) as CodingExpense 
FROM invoice
GROUP BY file_number

I am getting this error

Error in list of function arguments: '=' not recognized. Unable to parse query text.

I tried replacing IIF with SWITCH to no avail.
What's wrong with my query and how to correct this?

Upvotes: 1

Views: 403

Answers (1)

Fionnuala
Fionnuala

Reputation: 91356

AFAIK, you need that round the other way:

Sum(IIF(invoice_type="Spent on Coding",CINT(invoice_amount), 0)) as CodingExpense

However, I would suggest:

Round(Sum(IIF(invoice_type="Spent on Coding",invoice_amount, 0)),0) as CodingExpense

Upvotes: 1

Related Questions