Hallo Jose Manuel Jurado,
thank you for a post. I have a question.
SELECT cast(ValueText as float)
FROM Results
INNER JOIN Analyt
ON Results.ModelName = Analyt.ModelName
AND Results.DeviceTestID = Analyt.DeviceTestID
WHERE Results.NonNumericValue = 0
In some cases it raises an error "Error converting data type nvarchar to numeric." What is expected according the documentation. It is very hard to reproduce, but we know that it happens.
Does the move of condition to SELECT clause change an issue? Or it is translated similar way in the SQL engine? GitHub Copilot means it is the same, but my boss doesn't trust it.
SELECT CASE WHEN NonNumericValue = 0 THEN CAST(ValueText AS FLOAT) ELSE NULL END
FROM QC_Results
INNER JOIN Analyt_OC
ON QC_Results.ModelName = Analyt_OC.ModelName
AND QC_Results.DeviceTestID = Analyt_OC.DeviceTestID