Create Database Bank': Banking Example (Primary Key Is Underlined)
Create Database Bank': Banking Example (Primary Key Is Underlined)
Create Database Bank': Banking Example (Primary Key Is Underlined)
You can use command ‘show database;’ to check if ‘bank’ has been created.
Similarly, you can use command ‘show tables;’ to check if all tables have been created.
(3). Insert data into those tables (script can be downloaded from
http://www.cs.kent.edu/~nruan/bank_data.sql)
SQL:
use bank;
You can use SQL command ‘select * from [table_name];’ to check if data have been
inserted.
3. Find all employees whose salary is greater than 1400 and working branch is not
‘Downtown’
Answer: select * from employee where salary>1400 and branch_name<>’Downtown’;
4. Calculate the average salary of all employees and show the average salary as
“avg_salary”
Answer: select avg(salary) as avg_salary from employee ;
-------------------------------------------------
select distinct branch_name
from loan
;
-------------------------------------------------
select *
from Branch
;
-------------------------------------------------
select account_number from account
where balance > 700
;
-------------------------------------------------
select account_number, balance from account
where balance > 800 and branch_name = 'Brighton'
;
-------------------------------------------------
select branch_name, (assets / 1000) as 'assets in thousands'
from branch
;
-------------------------------------------------
select branch_name
from branch
where assets between 1000000 and 4000000
;
-------------------------------------------------
select customer_name, borrower.loan_number, amount
from borrower, loan
where borrower.loan_number = loan.loan_number and
branch_name = 'Perryridge';
-------------------------------------------------
select depositor.customer_name, account.account_number, balance
from depositor, account
where depositor.account_number = account.account_number
and balance <= 400
;