On Fri, Jun 02, 2006 at 10:09:01AM -0700, [EMAIL PROTECTED] wrote: > Michael, my derivative of your query example works > great - thank you! > > i think i understand everything except why multiplying > by 1.0 is necessary. when i take it out, my expected > result, 0.50000000000..., turns into 0 - so i assume > it has to do with formatting the result.
Integer division yields integers, so 1 / 2 = 0 whereas 1.0 / 2.0 = 0.5. The expression therefore needs something to force a non-integer result. Multiplying by 1.0 (or 100.0) is one way; using 1.0 and 0.0 in the CASE expression is another; casting one of the operands to numeric or one of the floating-point types is yet another. -- Michael Fuhr ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org