I have the following query:
SELECT
*,
CASE PORCENTAJE_CRUCE
WHEN PORCENTAJE_CRUCE >= 80.00 AND PORCENTAJE_CRUCE <= 85.99 THEN 2000
WHEN PORCENTAJE_CRUCE >= 86.00 AND PORCENTAJE_CRUCE <= 90.99 THEN 3000
WHEN PORCENTAJE_CRUCE >= 91.00 THEN 5000
ELSE 0
END AS PAGO_INCENTIVO
FROM #AR_PORCENTAJE
and the following error:
Incorrect syntax near '>'.
I suppose that the condition that I am putting after the WHEN
is incorrect, what would be the correct way to add these conditions after the WHEN
?
The expression
CASE
in SQL Server has 2 forms, in the first one you compare a column with equality conditions:Or if you want more elaborate comparisons than just the equality of a single column with some value:
Basically, in your case you just have to remove
PORCENTAJE_CRUCE
immediately afterCASE
: