That was correct again. There are also other rounding functions available in each database.
ceil(x) (in SQL Server –
ceiling()) returns the smallest
integer which is not less than
x. In other words, it always rounds up (13.7 will become 14, and so will 13.1).
floor(x) is the opposite of
ceil(x) – it always rounds down, so 13.7 will become 13.
trunc(x) (in MySQL –
truncate()) is yet another function which always rounds towards 0. For positive numbers, it works like
floor(x) (13.7 becomes 13). For negative ones, it works like
ceil(x) (-13.7 becomes -13).
What's more, each of the functions above can be used with a second argument to specify its precision, as in the case of
round(x, precision). When using the
round(x, precision) function with two arguments, PostgreSQL requires us to pass the first argument of the numeric type. Use casting when appropriate.