0% found this document useful (0 votes)
4 views1 page

SQL Queries for Loan and Account Analysis

Uploaded by

aboudarghampeter
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

SQL Queries for Loan and Account Analysis

Uploaded by

aboudarghampeter
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

--1

select Max(account_balance)
from account;

--2
select loan_number
from loan
where amount = (select min(amount) from loan);

--3
select t.cust_id,[Link]
from take as t, loan as l
where t.loan_number=l.loan_number
and [Link]= (select min(amount) from loan);

--4
select c.cust_name ,[Link]
from take as t, loan as l, customer as c
where t.loan_number=l.loan_number
and [Link]= (select min(amount) from loan);

--5
SELECT branch_name, SUM(amount) as totalamount
FROM loan
GROUP BY branch_name;

--6
select COUNT(account_number)
from account
where account_balance > (SELECT AVG(account_balance) FROM account);

--7
Select branch_name
from loan
group by branch_name
having AVG(amount) > 1250;

--8
SELECT h.cust_id, SUM(a.account_balance) as total_balance
FROM has h
JOIN account a ON h.account_number = a.account_number
GROUP BY h.cust_id;

--9
SELECT branch_name, SUM(amount) AS total_amount
FROM loan
WHERE branch_name != 'Downtown'
GROUP BY branch_name
HAVING SUM(amount) > 2000
ORDER BY branch_name ASC;
--10
SELECT branch_name, AVG(amount)
FROM loan
GROUP BY branch_name
HAVING COUNT(loan_number) > 1;

You might also like