Académique Documents
Professionnel Documents
Culture Documents
1
Aggregate Functions
2
Aggregate Function Computation
select avg(balance)
from account
where branch-name=“Perryridge”
3
Examples of Aggregate Functions
4
Group by
branch-name count-account-no
account table Perryridge 2
Brighton 2
Redwood 1
5
Group by Attributes
correct
branch- account- balance
select … from account name number
Perryridge a-102 400
group by branch-name, balance Perryridge a-201 900
OR Brighton a-217 750
select branch-name, sum(balance), count(…) Brighton a-215 750
Redwood a-222 700
from account group by branch-name
6
Group by with Join
7
Group by Evaluation
branch-name cust-name
Perryridge John Wong
Perryridge Jacky Chan count
select branch-name, customer-name Uptown John Wong
from depositor, account Uptown Mary Kwan
where depositor.account-number Downtown John Wong
Downtown Pat Lee branch-name count
= account.account-number Downtown May Cheung Perryridge 2
Uptown 2
join distinct Downtown 3
8
Having Clause (condition on the groups)
9
Having Clause
10
Derived Relations
11