Use of SQL Server (function) keywords three

Source: Internet
Author: User

three , function Key Words -- Introduction to use

The use of function (function of the built-in SQL functions)?

The syntax for the built-in SQL function is: SELECT function  from table)

avg () is used (avg () returns the average of the column)

The avg function returns the average of a numeric column. NULL values are not included in the calculation.  SELECTAVG from table_name


The use of Count () (count () for the specified number of columns)

COUNT The (column_name) function returns the number of values for the specified column (NULL does not count in):SELECTCOUNT from table_name


The use of First () returns the value of field one

ORDER  by statement to sort the records.  SELECT from table_name


Use ( last() returns the final value of a field)

ORDER  by statement to sort the records.  SELECT from table_name

Max ( ) is used (max () returns the maximum value in the column)

The max function returns the maximum value in a column. NULL values are not included in the calculation.  SELECTMax from table_name comments:MINMax It can also be used for text columns to get the highest or lowest values in alphabetical order.

Use of min () (min () returns the lowest value in the column)

The min function returns the minimum value in a column. NULL values are not included in the calculation.  SELECTmin from table_name Note:MINMAX can also be used for text columns, To get the highest or lowest value in alphabetical order.

The use of sum () (Sum() calculates the sum of the columns)

SUM The function returns the total number of numeric columns (total).  SELECTSUM from table_name


Aggregate functions, such as SUM, often require the addition of a GROUP by statement.

The use of GROUP by (grouping by combined aggregate functions)

GROUP  by statements are used in conjunction with aggregate functions to group result sets based on one or more columns.  SELECT  column_name, aggregate_function (column_name) from table_name  WHERE  column_name operator valueGROUP by column_name


Panax Notoginseng , having the use (having)?

 HAVING clause reason is that theWHERE  keyword cannot be used with an aggregate function.  SELECT  column_name, aggregate_function (column_name) from table_name  WHERE  column_name operator valueGROUP by column_name have Aggregate_function (column_name) operator value


UCase () use (UCase () to capitalize the value of the field)

The UCASE function converts the value of a field to uppercase.  SELECT from table_name


LCase () use (LCase () to lower the value of the field to lowercase)

The LCASE function converts the value of the field to lowercase.  SELECT from table_name


The use of Len () (len () field length)

LEN the function returns the length of the value in the Text field.  SELECTLEN from table_name

The use of round () (round () specifies the number of decimal digits)

ROUND The function is used to round a numeric field to a specified number of decimal digits.  SelectROUND from table_name Example:SelectROUND(UnitPrice, 0  as  from Products

Use ( now () to return the current time)

getdate () function to get the current date time.  SELECT from table_name


The use of format ( now() returns the current time)

The format () function is used for formatting the display of a field.  SELECT from table_name

Use of SQL Server (function) keywords three

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.