SQL function detailed

Source: Internet
Author: User
Tags expression min
function | Detailed SQL function, described in detail as follows:

Avg function

Avg function that calculates the arithmetic average of data in a particular field in a query.

The syntax is AVG (expression). An expression that can be a field name, a formula, or a function that can be
To be an internal or user-defined, but not a different SQL function.

The AVG function, when evaluated, does not contain any data that has a null value.

Count function

Count function, which calculates the number of record bars that match the query criteria.

The syntax is count (an expression). The expression can be a field name, *, multiple field names, expressions,
Or a function that can be an internal or user-defined, but not a different SQL function.

The Count function, when evaluated, does not contain any data with null values.

However, COUNT (*) calculates the number of record bars that match the query criteria, including those null data.

If the field name of Count (field name) is more than one field, use & separator between field names.
The Count function is evaluated as a single field in which the value of at least one of the fields is not NULL
Recording. If more than one field is null, it is not a single record. Such as:

SELECT Count (Price & code) from product

First/last function

The first function, the last function, that returns the last record in the specified field that matches the query criteria
of information.

The syntax is the "a" and last (expression). An expression that can be a field name, a formula, or a
A function that can be an internal or user-defined, but not a different SQL function.

Min/max function

The Min function, the Max function, returns the minimum and maximum values in the specified field that match the query criteria.

The syntax is min (expression) and Max (expression). An expression that can be a field name, a formula, or a
function, which can be an internal or user-defined, but not a different SQL function.

Stdev function

Stdev function that calculates the standard deviation in the specified field that matches the query criteria.

Syntax is stdev (expression). An expression that can be a field name, a formula, or a function, and this function
can be an internal or user-defined, but not a different SQL function.

If the record that matches the query criteria is two below, the STDEV function returns a null value that represents
The standard deviation cannot be computed.

Sum function

The SUM function that calculates the sum of the data in the specified field that matches the query criteria.

The syntax is sum (an expression). An expression that can be a field name, a formula, or a function that can be
To be an internal or user-defined, but not a different SQL function.

The SUM function can use two field data expressions, such as calculating the total unit price and quantity fields of a product:

SELECT Sum (unit price * quantity) from product

var function

var function, which evaluates the variance estimates in the specified field that match the query criteria.

The syntax is VAR (an expression). An expression that can be a field name, a formula, or a function that can be
To be an internal or user-defined, but not a different SQL function.

If the record that matches the query criteria is two below, the Var function returns a null value, which indicates that the
Can calculate the variance number.



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.