-1

I want a SQL query to return "VIDE" when the field is empty in Sales Cloud but I have an error message saying "Incorrect syntax near the keyword 'IF'.

Here is my SQL part : IF NULL (Code_Provenance__c, 'VIDE') as 'CODE_PROVENANCE',

  • I have founded a solution to my problem using CASE function. – Grégoire Sarrola Jan 20 at 14:44
  • 1
    Please either provide your solution as an accepted answer, or remove the question. – Lukas Lunow Jan 20 at 15:11
2

There are a few ways to resolve this (I know you mentioned in your comments that you utilized CASE to solve for it, but thought i should leave something as a reference for anyone else having this issue):

  1. CASE statements:
SELECT primarykey,
CASE
  WHEN field1 IS NULL THEN
    'Default Value'
  ELSE 
    field1
END as field1
FROM [myDE]
  1. ISNULL
SELECT primarykey,
ISNULL(field1,'Default Value') as field1
FROM [myDE]
  1. COALESCE
SELECT primarykey,
COALESCE(field1,'Default Value') as field1
FROM [myDE]

There may be a couple other ways to accomplish this, but these are three should handle most if not all use cases you may have.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.