Is it possible to use the function IIF in LibreOffice Base?

when creating a query in SQL, I can not use function IIF as in Access

hello Darya, you could try the CASEWHEN function instead:

CASEWHEN( <boolean value expr>, <value expr 2>, <value expr 3> )

If the [boolean value expr] is true, returns [value expr 2] otherwise returns [value expr 3]. Use a CASE WHEN expression instead for more extensive capabilities and options.

Ciao, you can use also CASE WHEN expr1 THEN v1[WHEN expr2 THEN v2] [ELSE v4] END

when expr1 is true return v1 [optionally repeated for more cases] [otherwise v4 or null if there is no ELSE]

Which SQL you can use depends a lot on which database you are connected to. :wink:

The default LO database is HyperSQL 1.8. It doesn’t allow many things.

I normally connect to MariaDB (a MySQL clone) which allows many, many things. In MySQL/MariaDB IIF is simply called IF, and you can simply use if(test, iftrue, iffalse) construct.

For links to the various database documentation/reference manuals see my post on this subject here.

(Also I should note that you can use IIF in LO Basic, but that’s not SQL.)