Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SELECT customer.Cust_ID, customer.address, loan.Loan_No, loan.Amount FROM customer JOIN loan on customer.Cust_ID = loan.Cust_ID WHERE loan.Amount > ALL (SELECT AVG(loan.Amount) FROM customer JOIN loan on customer.Cust_ID

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
SELECT customer.Cust_ID, customer.address, loan.Loan_No, loan.Amount FROM customer JOIN loan on customer.Cust_ID = loan.Cust_ID WHERE loan.Amount > ALL (SELECT AVG(loan.Amount) FROM customer JOIN loan on customer.Cust_ID = loan.Cust_ID); SELECT * FROM bank; SELECT account.Balance, account.Cust_ID FROM account WHERE account.Cust_ID = 1004; SELECT bank.B_name, customer.Cust_ID, customer.address, loan. Amount FROM bank, Customer, loan WHERE bank. code = customer .Bank_code AND customer.Cust_ID = loan.Cust_ID; SELECT branch.Branch_ID, branch.Branch_name FROM branch WHERE branch.Branch_name LIKE "P\%"; SELECT payment.Payment_no, payment.Payment_date FROM payment WHERE payment.Payment_date BETWEEN "2023-01-01" AND "2023-04-01"; SELECT loan.Cust_ID, loan.Loan_No, loan.Amount FROM loan WHERE loan.Amount NOT BETWEEN 12000.000 AND 25000.00 SELECT MAX(account.Account_No), account.Balance FROM account SELECT COUNT(loan.Amount) from loan WHERE loan.Amount > 20000 SELECT MAX(account.Balance) "Highest Balance", MIN(account.Balance) "Lowest Balance", AVG(account.Balance) "Average Balance", sUM(account.Balance)"Total Balance", COUNT(*) "Number of accounts" FROM account; SELECT loan.Cust_ID, loan.Amount FROM loan WHERE loan.Amount = (SELECT MAX(loan.Amount) FROM loan); SELECT payment.Payment_no, payment.Payment_amount FROM payment WHERE payment.Payment_amount > ALL (SELECT AVG(payment.Payment_amount) FROM payment); SELECT Customer.Bank_code, SUM(subquery.Total_Loan_Amount) AS Total_Loan_Per_Bank FROM ( SELECT Loan.Cust_ID, SUM(Loan.Amount) AS Total_Loan_Amount FROM Loan GROUP BY Loan.Cust_ID) AS subquery JOIN Customer ON subquery.Cust_ID = Customer.Cust_ID GROUP BY Customer.Bank_code; SELECT Customer.Bank_code, SUM(subquery.Total_Loan_Amount) AS Total_Loan_Per_Bank FROM ( SELECT Loan.Cust_ID, SUM(Loan.Amount) AS Total_Loan_Amount FROM Loan GROUP BY Loan.CUst_ID ) AS subquery JOIN Customer ON subquery.Cust_ID = Customer.Cust_ID GROUP BY Customer.Bank_code HAVING SUM(subquery.Total_Loan_Amount) >12000.00; SELECT Cust_ID, Balance FROM Account WHERE Account_No IN ( SELECT Account_No FROM Saving ) ORDER BY Balance DESC LIMIT 5; SELECT Customer.Cust_ID, Customer.address, Customer.Bank_code FROM Customer WHERE EXISTS ( SELECT 1 FROM Loan WHERE Loan.Cust_ID = Customer.Cust_ID AND Loan. Amount > 12000 ); UPDATE Customer_Mobile SET Mobile_no = NULL WHERE Cust_ID IN (1001,1002, 1003,1004,1005 ); SELECT A.Cust_ID, SUM(A.Balance) AS Total_Balance FROM Account A LEFT JOIN Customer_Mobile CM ON A.Cust_ID = CM.Cust_ID WHERE CM.Mobile_no IS NULL GROUP BY A.Cust_ID ORDER BY Total_Balance DESC LIMIT 5; SELECT Customer.Cust_ID, Customer.address, Customer.Bank_code FROM Customer WHERE Customer.Cust_ID IN ( SELECT Account.Cust_ID FROM ACcount JOIN Saving ON Account.Account_No = Saving.Account_No ); From the queries that you have submitted in the previous phase of the project (i.e. part 4), Select the most complex nested query to do the following: a) [2 Points] Specify the initial canonical query tree that corresponds to each query. b) [8 Points] Use query-processing steps to construct the suitable query tree for each SQL statement. show each step for query optimization. Discuss why your constructed query tree is or is NOT the optimal query tree. See "sport commute example" presented in the chapter 18 video lecture. Notice: * you may follow the steps in pages 686-689 you may draw query tree(s) by hand and submit (this must be v. clear and neat handwriting) you may use insert equation (in MS word) to type regular expression: - you can use F for representing aggregation (as script F ) - and on for representing JOIN operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

administer a survey to an appropriate sample of respondents;

Answered: 1 week ago

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago