Everybody that has had to do some numeric calculations in SQL
will have encountered this simple problem: divide an integer by
another integer and round down the outcome to the nearest
integer. In many cases people write it like this:
FLOOR(a/b)
Simple enough, right? First we do the division a/b,
then we round down using the function FLOOR().
Update: My claim that TRUNCATE(a/b, 0) is equivalent
to FLOOR(a/b) is false! It maybe true when the
outcome of the division is a positive number, but in case of a
negative number, TRUNCATE() will only lose the
decimals (resulting in a higher negative number) and
FLOOR() will still round down.
Thanks …