Bruno Wolff III <bruno@xxxxxxxx> writes: >>> Try: >>> order by count(id)/age::float >> >> Or you can use the standard grammer: >> >> order by cast(count(id)/age as float) > Don't you have to cast before the divide? Yeah. The :: case is OK because :: binds more tightly than / but the second suggestion is wrong :-( regards, tom lane