简体   繁体   中英

Select Case Oracle Missing Expression or Missing Keyword

I am trying to use CASE expression with SELECT with Oracle SQL developer and whatever I try doing I get a mistake. With the statement here under I get missing expression. I have checked and I think all required keywords are there. I tried modifying the code in many ways and the only thing that happens is sometimes I get

"missing keyword error".

SELECT 
      CASE WHEN A.PARENT_ID IS NULL THEN 'NOPROB'
                                    ELSE 'PROB'
      END AS 'PROBLEMS'
FROM A

Try this answer

SELECT 
      CASE WHEN PARENT_ID IS NULL THEN 'NOPROB'
                                    ELSE 'PROB'
      END AS PROBLEMS
FROM A

When giving an alias to a table name double quote is used not single qoute

SELECT 
     CASE WHEN A.PARENT_ID IS NULL THEN 'NOPROB'
                                   ELSE 'PROB'
     END AS "PROBLEMS"
FROM A

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM