I have a scalar named query that does a calculation on two values in a table and returns the answer. When the operator does not enter the values for that day, the query should return the fallback value of 0. However, it returns a unicode 0 instead. I have tried casting the value as a float in the query, but it still returns unicode. How can I either fix it in the query to return a value of 0.0 or fix it in the script where I run the query? In the script, I need the 0 to be a value because I am doing more calculations on it.
If it is MSSQL you can wrap the calculation in your query with a COALESCE
SELECT COALESCE([Field1]+[FIELD2],0.0) as Result
I think scalar NQs with a fallback always casts the result to a string. I've run into this issue before.
@dkhayes117 is correct per the code. Since their inception the fallback value in named queries has been hardcoded to string. ![]()
This didn't work. It still came back as unicode.
SELECT COELESCE((([End]-[Start]) *0.35),0.0) AS Tons
FROM [table]
WHERE [id] = :id
This worked!
