"Tore Lukashaugen" <tore(at)lukashaugen(dot)freeserve(dot)co(dot)uk> writes:
> create table test (col1 int, col2 int)
> insert into test values (1,2);
> select col1/col2 from test....yields 0 not 0.5 - why?
> Presumably this is because both col1 and col2 are ints and the output needs
> to be casted somehow?
Yup --- division of integers yields an integer result.
If you want a fractional result, cast one or both inputs of the division
to numeric or float.
regards, tom lane