272 Part I EXAM PREPARATION TABLE 5.1 AGGREGATE
272 Part I EXAM PREPARATION TABLE 5.1 AGGREGATE FUNCTIONS Function Description AVG() Average value of the group. BINARY_CHECKSUM(), Return a number representing the value of the data CHECKSUM(), and in the group. Useful for detecting data changes. CHECKSUM_AGG() COUNT(), COUNT_BIG() Number of objects in the group. MAX() Maximum value of the group. MIN() Minimum value of the group. SUM() Sum of the values in the group. STDEV(), STDEVP() Standard deviation of values in the group. VAR(), VARP() Variance of the values in the group. Aggregate functions take one of three types of arguments. Some take a simple wildcard (*). This means that the operation either doesn t apply to rows, or it should apply to all rows. Look at the following statement, for example: SELECT COUNT(*) FROM Person This example returns the number of rows in the Person table. The number of rows that are in the table is independent of any individual column. The COUNT() functions and the CHECKSUM() functions work this way. It applies the function across the entire group, regardless of the content of each row. All the functions take a column name as an argument, and then the aggregate applies only to that column. You could have used this in the preceding query: SELECT COUNT(PersonID) FROM Person This example returns the number of not-null PersonIDs in the table. Some functions enable you to apply the function to distinct values only. For example, if you want a count of the distinct values in a table, you can use COUNT (DISTINCT LastName), which provides a count of the number of distinct last names. The COUNT, AVG, and SUM functions support this and actually do something with it. MIN and MAX support it, but it doesn t mean anything; it is included only for SQL-92 compliance.
For high quality website hosting services please check cheap web hosting website.