lundi 19 août 2019

SQL Else If statement to return text value from numeric value of another column - not working

Calculated column in SQL - incorrect syntax

I need to have a calculated column [Site_Condition] that will return a text value based on the numeric value of another column: [Condition_Score] which is in the same table. Below is what I have tried inserting into the Computed Column Specification but get this message: "Error validating the formula". I have also tried creating it from script "Create table as" using same syntax below ie: Site_Condition AS (IF....) - what am I doing wrong? Thanks in anticipation

IF([Condition_Score]<0.51,'Very poor',(ELSE IF([Condition_Score]<1.51,'Poor', ELSE IF([Condition_Score]<2.51,'Moderate',ELSE IF([Condition_Score]<3.51,'Good',ELSE IF([Condition_Score]>3.51,'Excellent'))))))

I get incorrect syntax errors with the above code

Aucun commentaire:

Enregistrer un commentaire