Numeric function (learning notes), numeric function learning notes

Source: Internet
Author: User

Numeric function (learning notes), numeric function learning notes

-- ************************************ Digital functions
-- ABS: returns the absolute value.

SELECT ABS(3),ABS(-100) FROM dual;

Result: 3,100
-- CEIL rounded up

SELECT CEIL(3.34343),CEIL(3.932),CEIL(-3.4432),CEIL(-5.9889) FROM dual; 

Result: 4,4,-3,-5.


-- Floor rounded down

SELECT FLOOR(3.34343),FLOOR(3.932),FLOOR(-3.4432),FLOOR(-5.9889) FROM dual; 

Result: 3, 3,-4,-6.


-- Sin --- cosine

SELECT SIN(4),COS(4) FROM dual;

 

-- Power function power (m, n), n power of m

SELECT POWER(2,4) FROM dual;

Result: 16

 

-- Round
-- Verify the use of the round Function

Select round (785.652) does not retain decimal places, ROUND (785.652, 2) retains two decimal places, ROUND (785.652,-1) returns one integer, ROUND (785.352) the first digit of the decimal place is less than 5 rounded off, and the rounded digit (784.652,-1) is less than 5 rounded off FROM dual;

Result: 786,785.65, 790,785,780


-- List the basic information and daily salary of each employee. The daily salary is only kept at 2 decimal places, 30 days per month.

SELECT e. empno, e. ename, e. sal, round (e. sal/30, 2) daily salary FROM emp e;

 

-- Verify that the TRUNC function intercepts uncarried

Select trunc (785.652) does not retain decimal places, TRUNC (785.652, 2) retains two decimal places, TRUNC (785.652,-1) returns one integer, TRUNC (785.352) if the decimal number is retained, TRUNC (784.652,-1) rounds the entire number into a single digit FROM dual;

Result: 785,785.65, 780,785,780


-- Verify MOD for the remainder Function

SELECT MOD(10,3)FROM dual;

Result: 1


-- Square root sqrt

SELECT SQRT(16) FROM dual;

Result: 4

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.