CS 330
Lecture 8
Examples
Aggregate functions
- Find the average account balance at the Perryridge branch.
- Find the average account balance at every branch.
- Find the number of depositors for each branch.
- Find those branches where the average account balance is > 1200.
- Find the average balance for all accounts.
- Find the number of tuples in customer relation.
- Find the average balance for each customer who lives in Harrison and has at least 3 accounts.
Nested Queries
- Find all customers who have both a loan and an account.
- Find all customers who have both an account and a loan at the Perryridge branch.
- Find all customers who do have a loan, but do not have an account at the bank.
Set Comparisons.
Find names of all branches that have assets greater than those of at least one branch located in Brooklyn.
- Find names of all branches that have assets greater than the assets of
each branch located in Brooklyn.
- Find the branch that has the highest average balance.
Empty relations.
- Find all customers who have both an account and a loan at the bank.
- Find all customers who have an account at all branches located in Brooklyn.
Test for absence of duplicates.
- Find all customers who have only one account at the Perryridge branch.
- Find all customers who have at least two accounts at the Perryridge branch.
Ileana Streinu