sql - Case statement returning '0' -
i need case statement return empty string if value null or -1 it's returning 0. employeecount int , i'm assuming needs cast varchar nothing i've tried seems working.
case when employeecount = -1 '' when employeecount null '' else employeecount end this not working either:
case when employeecount = -1 '' when employeecount null '' else cast(employeecount varchar(10)) end
a case expression returns single type. if have then clauses evaluate strings , others evaluate numbers, database decide result number, not string. why seeing 0. '' looks when converted number.
the solution simple: cast() result string:
(case when employeecount = -1 or employeecount null '' else cast(employeecount varchar(32)) end)
Comments
Post a Comment