Getting this error - ORA-00936: missing expression

1k views Asked by At

I am new to SQL and trying to use an if statement equivalent in order to get the value in SQL.

After running this report I am getting the error "ORA-00936: missing expression"

 CASE WHEN (select Sum(MONTANT) from fraisExterne where matching=fm.id and statut=3) IS NULL 
   THEN select sum(MONTANT) from fraisExterne where matching=fm.id 
   ELSE Select sum (MONTANTHTBROKER) from fraismatching where matching=fm.id 
 End End as "BROKER AMOUNT"

Please let us know if you can help me with it

1

There are 1 answers

0
OLIVER.KOO On

You have a extra END key word at the end of your case statement. You also need to put your select query into ().

Try this:

 SELECT
 CASE
    WHEN (select Sum(MONTANT) from fraisExterne where matching=fm.id and statut=3) IS NULL THEN (select sum(MONTANT) from fraisExterne where matching=fm.id) 
    ELSE (Select sum (MONTANTHTBROKER) from fraismatching where matching=fm.id) 
 End AS BROKER_AMOUNT

I hope this helps and welcome to StackOverflow. If you find this answer or any other answer solves your problem please mark it as the solution. This will help the community and fellow programmers who run into the same problem in the future. Thanks.