0

i have a problem with CASE sintax (I think) and I hope you can help me. I'll try to explain my problem:

I have 2 fields DV_CODE e DV_NAME and I would like to have DV_NAME = 'Other person' if I haven't the code, that means DV_CODE = null

This is my code:

SELECT rep_code,
   name,
   act_date,
   dv_code,
   CASE
      WHEN DUAL_CODE_AM IS NULL THEN DV_NAME= 'Other person'
      WHEN DUAL_CODE_PM IS NULL THEN DV_NAME= 'Other person'
   END
   AS dv_name
  ......

(in my case "else"statment is useless)

but system returns to me 2 errors:

or: missing keyword or: missing parenthesis

thanks in advance.

6
  • Case EXPRESSION, not case statement... Commented May 22, 2015 at 13:26
  • I lost the first phrase: "Hi guys, nice to read you again" Commented May 22, 2015 at 13:29
  • You mention in your question you want to check DV_CODE IS null, but then in your sample code you check DUAL_CODE_AM IS NULL and DUAL_CODE_PM ?? so what are you checking for NULL? DV_CODE, DUAL_CODE_AM, or DUAL_CODE_PM ? Commented May 22, 2015 at 13:30
  • I'm sorry, this is the "correct code": SELECT rep_code, name, act_date, CASE WHEN DUAL_CODE_AM IS NULL THEN DV_NAME= 'Other person' WHEN DUAL_CODE_PM IS NULL THEN DV_NAME= 'Other person' END AS dv_name ...... i check if one of DUAL_CODE_AM OR DUAL_CODE_PM are NULL Commented May 22, 2015 at 13:32
  • @Solido you can edit your question and add this new snippet. Commented May 22, 2015 at 13:39

1 Answer 1

2
SELECT rep_code,
   name,
   act_date,
   CASE
      WHEN DUAL_CODE_AM IS NULL THEN 'Other person'
      WHEN DUAL_CODE_PM IS NULL THEN 'Other person'
   END
   AS dv_name
  ......
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.