SELECTround(45.923,2),round(45.923, 0),round(45.923, -1);
round(45.923,2)|round(45.923, 0)|round(45.923, -1)|
---------------+----------------+-----------------+
45.92| 46| 50|
SELECTtruncate(45.923, 2),truncate(45.923, 0),truncate(45.923, -1);
truncate(45.923, 2)|truncate(45.923, 0)|truncate(45.923, -1)|
-------------------+-------------------+--------------------+
45.92| 45| 40|
SELECTceil(45.923),CEIL(52.1);
ceil(45.923)|CEIL(52.1)|
------------+----------+
46| 53|
SELECTfloor(45.923),floor(52.1);
floor(45.923)|floor(52.1)|
-------------+-----------+
45| 52|
연산자 mod, %와 동일한 기능을 수행한다.
SELECTmod(157,10), 157MOD10, 157 % 10, 157 / 10;
mod(157,10)|157 MOD 10|157 % 10|157 / 10|
-----------+----------+--------+--------+
7| 7| 7| 15.7000|
SELECTmod(157,10), 157MOD10, 157 % 10,truncate(157 / 10, 0);
mod(157,10)|157 MOD 10|157 % 10|truncate(157 / 10, 0)|
-----------+----------+--------+---------------------+
7| 7| 7| 15|
SELECTlast_name, salary,mod(salary, 5000)
FROMemployees
WHEREjob_id ='SA_REP';
last_name |salary |mod(salary, 5000)|
----------+--------+-----------------+
Tucker |10000.00| 0.00|
Bernstein | 9500.00| 4500.00|
Hall | 9000.00| 4000.00|
Olsen | 8000.00| 3000.00|
Cambrault | 7500.00| 2500.00|
SELECTemployee_id,mod(employee_id, 2)
FROMemployees;
employee_id|mod(employee_id, 2)|
-----------+-------------------+
178| 0|
200| 0|
201| 1|
202| 0|
employee_id|
-----------+
178|
200|
202|
114|
116|
118|
120|
122|
124|
126|
SELECTabs(-5),abs(5),abs(-4.5);
abs(-5)|abs(5)|abs(-4.5)|
-------+------+---------+
5| 5| 4.5|
SELECTpower(2,3),power(4,1),power(4,0);
power(2,3)|power(4,1)|power(4,0)|
----------+----------+----------+
8.0| 4.0| 1.0|
SELECTsign(3),sign(-3),sign(0);
sign(3)|sign(-3)|sign(0)|
-------+--------+-------+
1| -1| 0|