Unable to use if
statement inside Select
in Oracle 12c
SELECT if(2 * 5 = 10, '1', null) AS a
FROM DUAL;
Try using case
:
SELECT CASE
WHEN 2 * 5 = 10 THEN '1' -- put the right condition here
ELSE null
END AS a
FROM DUAL;
Another possibility is Decode
:
SELECT Decode(2 * 5, 10, '1', null) AS a
FROM DUAL;
Please, note that IF ... THEN ... ELSE ... END IF
syntax is PL/SQL , not SQL one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.