Aggregating Data Using Group Functions: - 1
Aggregating Data Using Group Functions: - 1
Aggregating Data
Using Group Functions
Objectives
The maximum
salary in
the EMPLOYEES
table.
• AVG
• COUNT
• MAX
• MIN
• STDDEV
• SUM
• VARIANCE
You can use MIN and MAX for any data type.
SELECT MIN(hire_date), MAX(hire_date)
FROM employees;
EMPLOYEES
4400
9500 The
average
3500
salary
in
EMPLOYEES
6400
table
for each
department.
10033
EMPLOYEES
“Add up the
salaries in
the EMPLOYEES
table
for each job,
grouped by
department.
…
SELECT
SELECT department_id,
department_id, COUNT(last_name)
COUNT(last_name)
FROM
FROM employees;
employees;
SELECT
SELECT department_id,
department_id, COUNT(last_name)
COUNT(last_name)
**
ERROR
ERROR at
at line
line 1:
1:
ORA-00937:
ORA-00937: not
not aa single-group
single-group group
group function
function
Column
Column missing
missing in
in the
the GROUP BY clause
GROUP BY clause
Illegal Queries
Using Group Functions
The maximum
salary
per department
when it is
greater than
$10,000
…
Summary
Practice 5 Overview