TAILIEUCHUNG - SQL VISUAL QUICKSTART GUIDE- P20

SQL VISUAL QUICKSTART GUIDE- P20:SQL (pronounced es-kyoo-el) is the standard programming language for creating, updating, and retrieving information that is stored in databases. With SQL, you can turn your ordinary questions (“Where do our customers live?”) into statements that your database system can understand (SELECT DISTINCT city, state FROM customers;) | Chapter 6 Using Aggregate Functions Table lists SQL s standard aggregate functions. Using Aggregate Functions The important characteristics of the aggregate functions are In Table the expression expr often is a column name but it also can be a literal function or any combination of chained or nested column names literals and functions. SUM and AVG work with only numeric data types. MIN and MAX work with character numeric and datetime data types. COUNT expr and COUNT work with all data types. All aggregate functions except COUNT ignore nulls. You can use COALESCE in an aggregate function argument to substitute a value for a null see Checking for Nulls with COALESCE in Chapter 5. COUNT expr and COUNT never return null but return either a positive integer or zero. The other aggregate functions return null if the set contains no rows or contains rows with only nulls. Default column headings for aggregate expressions vary by DBMS use AS to name the result column. See Creating Column Aliases with AS in Chapter 4. Table Aggregate Functions Function Returns MIN expr Minimum value in expr MAX expr Maximum value in expr SUM expr Sum of the values in expr AVG expr Average arithmetic mean of the values in expr COUNT expr The number of non-null values in expr COUNT The number of rows in a table or set Tip DBMS DBMSs provide additional aggregate functions to calculate other statistics such as the standard deviation search your DBMS documentation for aggregate functions or group functions. 170 Summarizing and Grouping Data Creating Aggregate Expressions Aggregate functions can be tricky to use. This section explains what s legal and what s not. An aggregate expression can t appear in a WHERE clause. If you want to find the title of the book with the highest sales you can t use SELECT title_id --Illegal FROM titles WHERE sales MAX sales You cant mix nonaggregate row-by-row and aggregate expressions in a SELECT clause. A SELECT clause must contain either all .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.