Download presentation
Presentation is loading. Please wait.
1
Introduction to Oracle9i: SQL1 SQL Group Functions
2
Introduction to Oracle9i: SQL2 Chapter Objectives Differentiate between single-row and multiple-row functions Use the SUM and AVG functions for numeric calculations Use the COUNT function to return the number of records containing non-NULL values Use COUNT(*) to include records containing NULL values
3
Introduction to Oracle9i: SQL3 Chapter Objectives Use the MIN and MAX functions with non- numeric fields Determine when to use the GROUP BY clause to group data Identify when the HAVING clause should be used List the order of precedence for evaluating WHERE, GROUP BY, and HAVING clauses
4
Introduction to Oracle9i: SQL4 Chapter Objectives State the maximum depth for nesting group functions Nest a group function inside a single-row function Calculate the standard deviation and variance of a set of data, using the STDDEV and VARIANCE functions
5
Introduction to Oracle9i: SQL5 Group Functions Return one result per group of rows processed Also called multiple-row and aggregate functions All group functions ignore NULL values except COUNT(*) Use DISTINCT to suppress duplicate values
6
Introduction to Oracle9i: SQL6 SUM Function Calculates total amount stored in a numeric column for a group of rows
7
Introduction to Oracle9i: SQL7 AVG Function Calculates average of numeric values in a specified column
8
Introduction to Oracle9i: SQL8 COUNT Function Two purposes: –Count non-NULL values –Count total records, including those with NULL values
9
Introduction to Oracle9i: SQL9 COUNT Function – Non-NULL Values Include column name in argument to count number of occurrences
10
Introduction to Oracle9i: SQL10 COUNT Function – NULL Values Include asterisk in argument to count number of rows
11
Introduction to Oracle9i: SQL11 MAX Function Returns largest value
12
Introduction to Oracle9i: SQL12 MIN Function Returns smallest value
13
Introduction to Oracle9i: SQL13 GROUP BY Clause Used to group data Must be used for individual column in the SELECT clause with a group function Cannot reference column alias
14
Introduction to Oracle9i: SQL14 GROUP BY Example
15
Introduction to Oracle9i: SQL15 HAVING Clause// Serves as the WHERE clause for grouped data
16
Introduction to Oracle9i: SQL16 Order of Clause Evaluation When included in the same SELECT statement, evaluated in order of: –WHERE –GROUP BY –HAVING
17
Introduction to Oracle9i: SQL17 Nesting Functions Inner function resolved first Maximum nesting depth: 2
18
Introduction to Oracle9i: SQL18 Statistical Group Functions Based on normal distribution Includes: –STDDEV –VARIANCE
19
Introduction to Oracle9i: SQL19 STDDEV Function Calculates standard deviation for grouped data
20
Introduction to Oracle9i: SQL20 VARIANCE Function Determines data dispersion within a group
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.