- Rounds value to specified decimal
- Truncates value to specified decimal
- Returns remainder of division

ROUND Function
- ROUND function rounds the column, expression, or value to n decimal places. If the second argument is 0 or is missing, the value is rounded to zero decimal places. If the second argument is 2, the value is rounded to two decimal places. Conversely, if the second argument is –2, the value is rounded to two decimal places to the left (rounded to the nearest unit of 10).
- The ROUND function can also be used with date functions.
- SELECT ROUND(45.923,2), ROUND(45.923,0), ROUND(45.923,-1);
- 45.92 46 50
- TRUNC function truncates the column, expression, or value to n decimal places.
- TRUNC function works with arguments similar to those of the ROUND function. If the second argument is 0 or is missing, the value is truncated to zero decimal places. If the second argument is 2, the value is truncated to two decimal places. Conversely, if the second argument is –2, the value is truncated to two decimal places to the left. If the second argument is –1, the value is truncated to one decimal place to the left.
- Like the ROUND function, the TRUNC function can be used with date functions.
- SELECT TRUNC(45.923,2), TRUNC(45.923,0),TRUNC(45.923,-1);
- 45.92 45 50
- The MOD function finds the remainder of the first argument divided by the second argument.
- For all employees with job title of Sales Representative, calculate the remainder of the salary after it is divided by 5,000.
- SELECT ename, sal, MOD(sal, 5000) FROM emp WHERE job = 'SALESMAN';
- The above example calculates the remainder of the salary after dividing it by 5,000 for all employees whose job ID is SALESMAN
Thanks for this, just came across it.
ReplyDelete