Q:

SQL CASE statement issue

I have a problem of else case in SQL case statement.
In my SQL table column L_Keyword2 contains below value and is of varchar type.
YES,
LAND INCLUDED,
N/APPLICABLE,
3,
1.5,
NO,
4.5+,
OTHER,
NULL,
2,
1,
LAND LEASED,
0,
3.5,
N/A,
OE,
4,
2.5,

When I use this column in case statement like as 
SELECT 
    L_Keyword2,
    CASE 
       WHEN class LIKE 'RE_1' THEN L_Keyword2 ELSE 0 END
FROM Mytable

This SQL query throws an error:

Conversion failed when converting the varchar value '1.5' to data type int.

Why does this SQL query cause a conversion error? Even I am not done any conversion in it.

A:

Maybe this:
SELECT 
    L_Keyword2,
    CASE 
       WHEN class LIKE 'RE_1' THEN L_Keyword2 ELSE '0' END
FROM Mytable

If you want to use LIKE put % wildcard. Otherwise it is simple comparison (WHEN class = 'RE_1').

