Les 04
Les 04
Les 04
Related Data
Objectives
4-2
[column,] group_function(column). . .
table
condition]
group_by_expression]
column];
Example:
SELECT AVG(salary), STDDEV(salary),
COUNT(commission_pct),MAX(hire_date)
FROM
employees
WHERE job_id LIKE 'SA%';
4-3
Syntax:
SELECT
FROM
[WHERE
[GROUP BY
[ORDER BY
[column,] group_function(column). . .
table
condition]
group_by_expression]
column];
Example:
SELECT
4-4
4-5
[column,] group_function(column)...
table
condition]
group_by_expression]
having_expression]
column];
4-6
ROLLUP Operator
SELECT
FROM
[WHERE
[GROUP BY
[HAVING
[ORDER BY
4-7
[column,] group_function(column). . .
table
condition]
[ROLLUP] group_by_expression]
having_expression];
column];
2
3
4-8
CUBE Operator
4-9
[column,] group_function(column)...
table
condition]
[CUBE] group_by_expression]
having_expression]
column];
1
2
3
4
4-10
GROUPING Function
[column,] group_function(column) .. ,
GROUPING(expr)
FROM
table
[WHERE
condition]
[GROUP BY [ROLLUP][CUBE] group_by_expression]
[HAVING
having_expression]
[ORDER BY column];
4-11
3
4-12
GROUPING SETS
4-13
department_id, job_id,
manager_id,avg(salary)
FROM
employees
GROUP BY GROUPING SETS
((department_id,job_id), (job_id,manager_id));
4-15
Composite Columns
4-17
1
2
3
4
4-19
Concatenated Groupings
4-21
1
2
3
4-22
Summary
Practice 4: Overview
4-24