Thanks for taking the time John,

It does not seem to matter what the underlying column type is defined at,
SELECT 42 / 9 will always return an integer division.

I fool SQLite by always adding 0.00 to my numbers incase they happen to be
integer values in that row,

SELECT (col1 + 0.00) / (col2 + 0.00)

However this feels like a bodge.  Casting does not fix it either.

SELECT CAST(CAST(col1 AS NUMERIC) / CAST(col2 AS NUMERIC) AS NUMERIC)

still returns an integer if col1 and col2 happen to contain integer values.

What does everyone else do to ensure the division always returns a float?

Mike
--
View this message in context: 
http://www.nabble.com/Integer+-+Numeric+calculations-t1661126.html#a4501777
Sent from the SQLite forum at Nabble.com.

Reply via email to