I need to convert the following piece of code from SAS into an SQL case statement.
CASE WHEN (INDEX(UPCASE(SALES_STATUS), 'FORM RECEIVED')) >= 1 THEN 'Form Received'
I am struggling with the functions and the syntax and I am quite new to SQL.
Actually, it is not quite correct. It worked probably because your database has case-insensitive collations, or because the sales_status column had all upper case. Really it should be like this:
CASE
WHEN (CHARINDEX('FORM RECEIVED', UPPER(SALES_STATUS))) >= 1 THEN 'Form Received'
ELSE 'Form not received' -- this line is optional
END