Instruction
That was correct again. There are also other rounding functions available in each database.
ceil(x)(in SQL Server –ceiling()) returns the smallestintegerwhich is not less thanx. In other words, it always rounds up (13.7 will become 14, and so will 13.1).floor(x)is the opposite ofceil(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 likefloor(x)(13.7 becomes 13). For negative ones, it works likeceil(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).
As with the function round, in PostgreSQL the first argument of the rounding functions has to be of type numeric. Use casting when appropriate.
Now you really understand that there are various approaches to rounding!
Exercise
Let's check some rounding functions in the next few exercises. Show the character's name together with its weight, followed by the weight rounded up (name this column weight_rounded_up.
Stuck? Here's a hint!
Use ceil(weight).



