Skip to content
Advertisement

How to create a new column using existing column in SQL Redshift

I am trying to create a new column in SQL with certain conditions in DBVisualizer by connecting redshift data source. I used the following command to achieve the results but getting syntax error. I would be really grateful for any help.

Code:

Error:

Expected Output:

Thanks.

Advertisement

Answer

As stated in the error message, the IF() function does not exist in Redshift. Therefore, you should use CASE:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement