I have a problem with below SQL code. Error message: "Error converting data type varchar to float."
So the field 'volatility' is of datatype 'varchar', while 'NA' is datatype 'float', right?
I guess it can be solved by using CONVERT in the ELSE part. But how to do is not clear to me. It should be something like this:
But I need to have the value 'NA' in the field volatility if the when conditions are not met.
Many thanks for your help.
Code:
CASE WHEN ... THEN volatility else 'NA' end) as volatility
So the field 'volatility' is of datatype 'varchar', while 'NA' is datatype 'float', right?
I guess it can be solved by using CONVERT in the ELSE part. But how to do is not clear to me. It should be something like this:
Code:
CASE WHEN ... THEN volatility else CONVERT(float,volatility) end) as volatility
But I need to have the value 'NA' in the field volatility if the when conditions are not met.
Many thanks for your help.