Use SQL for function Query

Source: Internet
Author: User

[Ceil] Function

"Select Mgr, Mgr/100, Ceil (Mgr/100) from Scott. EMP;

Function usage: Ceil (n), which is the smallest integer greater than or equal to the value n.

[FLOOR] Function

Select Mgr, Mgr/100, floor (Mgr/100) from Scott. EMP;

Function usage: floor (n), which is the maximum integer less than or equal to the value n.

[Mod] Function

Select Mgr, MOD (MGR, 1000), MOD (MGR, 100), MOD (MGR, 10) from Scott. EMP;

Function usage: Mod (m, n), returns the remainder of m after division of N.

[Power] Function

Select Mgr, power (MGR, 2), power (MGR, 3) from Scott. EMP;

Function usage: Power (m, n), N to the power of M.

[Round] Function

Select Mgr, round (Mgr/100,2), round (Mgr/1000,2) from Scott. EMP;

Function usage: round (m, n), rounding, retaining n digits

[Sign] Function

Select Mgr, mgr-7800, sign (mgr-7800) from Scott. EMP;

Function usage: Sign (n ). N> 0, 1; n = 0, 0; n <0,-1.

[AVG] Function

Select AVG (MGR) average salary from Scott. EMP;

Function usage: AVG (field name), calculate the average value. The field must be numeric.

[Count] Function

Select count (*) Total number of records from Scott. EMP;

"Select count (distinct job) Total number of job categories from Scott. EMP;

Function usage: Count (field name) or count (*), count the total number.

[Min] Function

Select min (SAL) minimum salary from Scott. EMP;

Function usage: min (field name), used to calculate the minimum number of numeric fields.

[Max] Function

Select max (SAL) highest salary from Scott. EMP;

Function usage: max (field name), used to calculate the maximum number of numeric fields.

[Sum] Function

Select sum (SAL) Salary sum from Scott. EMP;

Function usage: sum (field name) to calculate the sum of Numeric Fields

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.