Forum Discussion
Inserting empty rows
- Feb 04, 2021
Clayton_cramer If you don't like IIF, then use IN:
SELECT year, Abs(Sum([cause_ID] In (15, 16))) AS incidents FROM Table2 GROUP BY year;
wrong number of arguments used in query function lif([cause_ID) = 15 or [cause_ID]=16'.
Clayton_cramerlif looks like a typo for if, but "undefined function 'if' in expression."
- George_HepworthJan 26, 2021Silver Contributor
Iif() is the immediate If function; that's how it is spelled.
There must be a different syntax error in my suggested approach. It's aircode since I don't have visibility to your actual table(s). See if you can suss it out, but post back if not.
- George_HepworthJan 26, 2021Silver Contributor
Wait, there may be a missing left paren. Add a second one after the first one
- Clayton_cramerJan 26, 2021Copper Contributor
George_Hepworth I added that parenthesis and now I get "Your query does not include the specified expression 'lif([cause_ID]15 Or [cause_ID=16,count(year),0)' as part of an aggregate function.
SELECT year, Iif(([cause_ID] = 15 or [cause_ID]=16), count(year), 0) AS incidents
FROM Table2
GROUP BY year;
I would upload the database, but it is huge: every mass murder in American history from 1657 to 1914 (so far). year is a number, cause_ID is a number.