Instruction
Amazing! Now let's summarize what we've learned in this part:
- Computations using floating point numbers are not always exact. Use the
decimal,numeric, ormoneydata types for all money columns and whenever precision matters. - Dividing two integers is integer division, which is not always accurate. Use
CAST(column AS TYPE)or the::operator to avoid it. - Avoid division by zero.
We've learned some useful functions:
- The modulo operation (
x % y) returns the remainder ofxbyydivision. ROUND(x, p)roundsxto the nearest integer or to the specified number of decimal digits (p).CEILING(x)rounds up to the nearest integer value.FLOOR(x)rounds down to the nearest integer value.ABS(x)returns the absolute value ofx.TRUNC(x, p)– removes decimal digits given inpfrom the numberx;TRUNC(x)removes all decimal digits.- The
::operator and theCAST()function convert data types.
The queries we've written so far have been fairly simple. Let's test your knowledge with some more advanced exercises.
Exercise
Click to continue.



