Recently doing an east with access, which uses the way case, but access does not support this syntax, query know IIF and Swith can be substituted, summarized as follows:
IIf (expr, Truepart, Falsepart)
The IIF function syntax contains the following named arguments:
Section description
The necessary parameters for expr. An expression used to determine authenticity.
Truepart necessary parameters. If expr is True, the value or expression of this part is returned.
Falsepart necessary parameters. If expr is False, the value or expression for this part is returned.
Instance:
SELECT q_sellout.*,
IIF (sell_month= ' 1 ' or sell_month= ' 2 ' or sell_month= ' 3 ', ' Q1 ', IIf (sell_month= ' 4 ' or sell_month= ' 5 ' or sell_month= ' 6 ', ' Q2 ', IIF (sell_month= ' 7 ' or sell_month= ' 8 ' or sell_month= ' 9 ', ' Q3 ', IIF (sell_month= ' or sell_month= ' one ' or sell_month= ') ' Q4 ', ' Error ')))) as Acct_quarter
From Q_sellout;
The above implementation is to find out which quarter a month belongs to.
Additional switch mode:
SELECT UserID,
UserName,
SWITCH (
Sex = ' f ', ' male ',
Sex = ' m ', ' woman ',
True, ' confidential '
) as Sexname
From TUser
The last case in the above is true, and the usage is similar to the else in case syntax.