Question

In: Computer Science

Find the total amount of ’Deposit’ transactions at the bank Find the list of transactions (statement)...

  1. Find the total amount of ’Deposit’ transactions at the bank
  2. Find the list of transactions (statement) of September 2019 (09/01/2019 to 09/30/2019) for account ’1111222233331441’ (note: look at the date format).
  3. Find the balance of ’1111222233331441’ before 09/01/2019 ((not including 09/01/2019).
  4. Find the name of the customer that deposited the highest amount with one transaction (include the transaction amount).

The SQL code to solve these problems is below:

DROP DATABASE IF EXISTS Bank;
CREATE DATABASE Bank;
USE Bank;

DROP TABLE IF EXISTS transaction;
DROP TABLE IF EXISTS customer;
DROP TABLE IF EXISTS account;


CREATE TABLE customer (
name VARCHAR(20),
sex CHAR(1),
ssn CHAR(9) NOT NULL,
phone CHAR(15),
dob DATE,
address VARCHAR(50),
PRIMARY KEY(ssn)

);
  
CREATE TABLE account (
number CHAR(16) UNIQUE NOT NULL,
open_date DATE,
type CHAR(20),
owner_ssn CHAR(9) NOT NULL,
PRIMARY KEY(number)
);
  
CREATE TABLE transaction (
id INT(20) UNIQUE NOT NULL,
amount DECIMAL(9,2),
tdate DATE,
type CHAR(10),
account_num CHAR(16),
PRIMARY KEY(id)
);


INSERT INTO customer VALUE ('John Adam', 'M', '512432341', '(438) 321-2553', '1987-11-15',NULL);
INSERT INTO customer VALUE ('Alexander Felix', 'M', '724432341', '(541) 321-8553', '1991-05-22', NULL);
INSERT INTO customer VALUE ('Andrew William', 'M', '861894272', '(308) 692-1110', '1995-01-04', NULL);
INSERT INTO customer VALUE ('Ana Bert', 'F', '844192241', '(203) 932-7000', '1982-12-07', '23 Boston Post Rd, West Haven, CT 06516');

INSERT INTO account VALUE ('1111222233331441', '2018-12-03', 'Checking', '861894272');
INSERT INTO account VALUE ('2111222233332442', '2019-01-06', 'Saving', '512432341');
INSERT INTO account VALUE ('3111222233333443', '2017-09-22', 'Checking', '844192241');
INSERT INTO account VALUE ('4111222233335444', '2016-04-11', 'Checking', '724432341');
INSERT INTO account VALUE ('5111222233339445', '2018-11-05', 'Saving', '724432341');
INSERT INTO transaction VALUE (1001, 202.50, '2019-08-15', 'Deposit', '5111222233339445');
INSERT INTO transaction VALUE (1002, 100.00, '2019-09-21', 'Deposit','2111222233332442');
INSERT INTO transaction VALUE (1003, 200.00, '2019-09-29', 'Deposit', '2111222233332442');
INSERT INTO transaction VALUE (1004, 50.00, '2019-09-29', 'Deposit', '2111222233332442');
INSERT INTO transaction VALUE (1005, 1000.00, '2019-09-29', 'Deposit','3111222233333443');
INSERT INTO transaction VALUE (1006, -202.50, '2019-08-29', 'Withdraw', '5111222233339445');
INSERT INTO transaction VALUE (1007, 50.00, '2019-09-29', 'Deposit', '2111222233332442');
INSERT INTO transaction VALUE (1008, 50.00, '2019-09-29', 'Deposit', '2111222233332442');
INSERT INTO transaction VALUE (1009, -10.00, '2019-09-26', 'Withdraw', '2111222233332442');
INSERT INTO transaction VALUE (1010, 50.00, '2019-09-29', 'Deposit', '4111222233335444');
INSERT INTO transaction VALUE (1011, 320.00, '2019-09-29', 'Deposit', '5111222233339445');
INSERT INTO transaction VALUE (1012, 50.00, '2019-09-18', 'Deposit', '4111222233335444');
INSERT INTO transaction VALUE (1013, 5000.00, '2019-06-21', 'Deposit', '1111222233331441');
INSERT INTO transaction VALUE (1014, -100.00, '2019-09-02', 'Withdraw', '1111222233331441');
INSERT INTO transaction VALUE (1015, -200.00, '2019-09-08', 'Withdraw', '1111222233331441');

Solutions

Expert Solution

The total amount of ’Deposit’ transactions at the bank :


select sum(amount) as 'total amount of Deposit' from transaction
where type='Deposit';

Query result :

*********************************

The list of transactions (statement) of September 2019 (09/01/2019 to 09/30/2019) for account ’1111222233331441’ (note: look at the date format) :


select id,amount,tdate,type from transaction where account_num=1111222233331441
and tdate between '2019-09-01' and '2019-09-30';

Query result :

******************************

The balance of ’1111222233331441’ before 09/01/2019 ((not including 09/01/2019) :

select sum(amount) as 'Balance' from transaction where account_num=1111222233331441
and tdate<'2019-09-01';

Query result :

*****************************

The name of the customer that deposited the highest amount with one transaction (include the transaction amount) :

select name,amount from customer inner join account
on customer.ssn=account.owner_ssn
inner join transaction on account.number=transaction.account_num
group by name
having amount=(select max(amount) from transaction where type='Deposit');

Query result :


Related Solutions

Find the compound amount for the deposit and the amount of interest earned. $230 at 5.2%...
Find the compound amount for the deposit and the amount of interest earned. $230 at 5.2% compounded semiannually for 17 years The compounded amount after 17 years is $____?. The amount of interest earned is $_____?
The Bank Statement Balance is $10,000. The Book Balance is $12,000. The is a Deposit in...
The Bank Statement Balance is $10,000. The Book Balance is $12,000. The is a Deposit in Transit of $2000. There is an Outstanding Check of $1000. There is an NSF Check from a customer of $1000. Based on this data, complete a bank reconciliation
Find the amount of the level deposit made at the start of each week for 10...
Find the amount of the level deposit made at the start of each week for 10 years at a nominal annual rate of 5.2% compounded weekly that will permit payment of 10,000 at the start of each year perpetually starting at the beginning of the 11th year. Assume that a year is exactly 52 weeks.
Find the amount needed to deposit into an account today that will yield a typical pension...
Find the amount needed to deposit into an account today that will yield a typical pension payment of $35,000 at the end of each of the next 30 years for the given annual interest rate. (Round your answer to the nearest cent.) 7.7% $_______
A bank reconciliation is a. A formal financial statement that list all of the bank account...
A bank reconciliation is a. A formal financial statement that list all of the bank account balances of an enterprise. b. A merger of two banks that previously were competitors. c. A statement sent by the bank to depositor on a monthly basis. d. A schedule that accounts for the differences between an enterprise’s cash balance as shown on its bank statement and the cash balance shown in its general ledger.
Prepare a balance sheet and income statement as a result of the following transactions: Owner deposit...
Prepare a balance sheet and income statement as a result of the following transactions: Owner deposit of $2000 to open a bank account Owner deposits and additional $500 in the bank account to increase his/her equity Purchase a used hand truck for $600 Bought insurance for the truck.  Insurance cost is $40 for the month. Placed a newspaper ad for $25 Purchased ladders for $300 Completed first job and was paid $2700 in cash Purchased $200 in supplies Rented a sprayer...
Prepare a balance sheet and income statement as a result of the following transactions: Deposit $3000...
Prepare a balance sheet and income statement as a result of the following transactions: Deposit $3000 in a bank account Rent a van at a cost of $400 Purchase a power sweeper for $900 Order 2000 circulars and paid the printer $120 Purchase $300 worth of cleaning supplies Bought equipment worth $900; paid $200 now and will pay the balance later. Earned $350 for washing windows Received $900 in fees for work performed Purchased supplies for $80, with cash Hired...
Exercise 18.1 Effects of transactions on statement of cash flows Below is a list of transactions...
Exercise 18.1 Effects of transactions on statement of cash flows Below is a list of transactions completed by Direct Fashion during 2020. Ignore GST. For each transaction, indicate (a) the section (i.e. operating, investing or financing) of the statement of cash flows (SCF) in which the cash effect is reported (if the effect is not reported in any of the sections, place NA on the line); (b) the amount; (c) whether the effect would be an inflow (+) or outflow...
Find the annual deposit of equal amount needed in Year 2 through Year 5
Find the annual deposit of equal amount needed in Year 2 through Year 5 (End of Year 2 through End of Year 5) to provide for annual withdrawals of $1,500 at the end of years 6, 7, 9 and 10 at an interest rate of 12% per year compounded yearly.
1. Find the correct excel formula to find the total in a retirment account: Monthly Amount...
1. Find the correct excel formula to find the total in a retirment account: Monthly Amount = $1250 Interest Rate = 2.0% Years in Account = 12.3 2. How much interest did you gain if you invested in a retirement plan with a rate of 2.5% over 42 years? Your monthly deposits totaled $520.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT