Consider the query below.  The Quantity column is of type REAL
SELECT Quantity
FROM foo
WHERE ID = 202224
However, doing a SUM results in many fractional digits (e.g. digits after decimal place):
SELECT SUM(Quantity)
FROM foo
WHERE ID = 202224
I can fix it by casting the result back to REAL:
SELECT CAST(SUM(Quantity) AS REAL)
FROM foo
WHERE ID = 202224
This feels like the wrong way to solve this problem.  And it adds an extra Compute Scalar to the query plan.
Is there a better way to solve this problem?



