I gave you wrong information ro start about REAL, wasn't thinking.

I look at the column type and if it returns an integer transform it to a float.

Mikey C wrote:
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