Review
So you think you can count?
Rounding functions and more
18. Other rounding functions
Review and practice

Instruction

Great job!

There are also other rounding functions you can use:

  • CEILING(x) returns the ceiling of x, which is the smallest integer greater than or equal to x. In other words, it always rounds up (the ceiling of 13.7 is 14, and so is 13.1, but the ceiling of 13 is just 13). The result of CEILING(-5.4) is -5.
  • FLOOR(x) is the opposite of CEILING(x)—it returns the greatest integer less than or equal to x (i.e., it always rounds x down). So the floor of 13.7 is 13, and so is 13.1. But the floor of 13 is just 13. The result of FLOOR(-5.4) is -6.

Now you really understand that T-SQL offers various approaches to rounding!

Exercise

Let's do some rounding. Show the character's name and actual weight, followed by the weight rounded up. Name the column UpWeight.

Stuck? Here's a hint!

Use CEILING(Weight).