- http://tuandao.info/html/career/SQL.pdf
- http://www.techinterviews.com/sql-interview-questions-and-answers
- create table branch
(branch_name char(15),
branch_city char(30) not null,
assets integer,
primary key (branch_name)) - insert into account
values ('A-9732', 'Perryridge', 1200) - delete from account
- select distinct branchname from loan
- select all branchname from loan
- Rename operation :
select customer_name, borrower.loan_number as loan_id, amount
from borrower, loan
where borrower.loan_number = loan.loan_number - select distinct customer_name
from borrower, loan
where borrower loan_number = loan.loan_number and
branch_name = 'Perryridge'
order by customer_name - Aggregate functions
- select branch_name, count (distinct
customer_name)
from depositor, account
where depositor.account_number = account.account_number
group by branch_name - Attributes in select clause outside aggregate functions must appear in group by clause
- Having clause
-
select branch_name, avg (balance)
from account
group by branch_name
having avg (balance) > 1200 - Predicates in the having clause are applied before forming groups and predicates in the where clause are applied before forming groups
- sd
- sd
- as
- select avg (balance)
from account where branch_name = 'Perryridge' - select count (distinct customer_name)
from depositor
- sd
No comments:
Post a Comment