Math operator
The
standard ANSI SQL-92 supports the following four basic arithmetic operators:
+
|
Add
|
-
|
Reducing
|
*
|
By
|
/
|
Except
|
%
|
Find Yu
|
Where the residual operator determines the remainder of the division. This operator is not supported by ANSI SQL, but the vast majority of databases support him. Here are some useful math functions, because they might be used, so I'm going to focus on this here. These functions are not supported in ANSI SQL-92, but they may be valid for some special RDBMS. However, they are effective for several major database systems. Let's talk about these math functions:
abs (x) |
returns the absolute value of x |
SIGN (x) |
|
mod (x,y) |
returns the remainder of x divided by Y, same as x%y |
floor (x) |
|
ceiling (x) or ceil (x) |
|
power (x,y) |
|
round (x) |
|
round (x,d) |
|
sqrt (x) /td> |
|
Here's an example:
SELECT Round (Salary), FirstName
From Employee_info
The above statement selects the closest number of salary and FirstName columns from the Employee_info table.