tailieunhanh - Using Functions phần 1

Using Functions SQL Server provides a number of functions you can use to get values from the database. | Using Functions SQL Server provides a number of functions you can use to get values from the database. For example you can use the COUNT function to get the number of rows in a table. The various functions are split into the categories shown in Table . Table FUNCTIONS FUNCTION CATEGORY DESCRIPTION Aggregate Return information based on one or more rows in a table. Mathematical Perform calculations. String Perform string manipulations. Date and time Work with dates and times. System Return information on SQL Server. Configuration Return information on the configuration of the server. Cursor Return information on cursors. Metadata Return information on the database and the various database items such as tables. Security Return information on the database users and roles. System statistical Return statistical information on SQL Server. Text and image Perform text and image manipulations. You ll learn about the first five functions in the following sections. The other categories of functions are beyond the scope of this book as they are of primary interest to database administrators. You can learn about those functions in the SQL Server Online Books documentation. Using Aggregate Functions Earlier you saw the use of the COUNT aggregate function to get the number of rows. COUNT and some other aggregate functions you can use with SQL Server are listed in Table . The expression you may pass to the aggregate functions is typically a single column but it can also be a calculated field. ALL means that the function is applied to all the column values while DISTINCT means that the function is applied only to unique values. ALL is the default. Table AGGREGATE FUNCTIONS FUNCTION DESCRIPTION Table AGGREGATE FUNCTIONS FUNCTION DESCRIPTION AVG ALL DISTINCT expression Returns the average of the values in a group. COUNT ALL DISTINCT expression Returns the number of rows in a group. COUNT returns an int data type value. COUNT_BIG ALL DISTINCT expression Returns the .

TÀI LIỆU LIÊN QUAN
10    158    1
6    184    1
7    162    1
5    157    1
6    160    1
6    152    1
6    150    1
6    206    1
7    154    1
5    121    1