0% found this document useful (0 votes)
7 views7 pages

Samir Rahman Sec02 LAB03

The document contains a series of SQL queries related to a database assignment for a course on Database Systems. Each query retrieves specific information from a database involving customers, loans, accounts, and branches, with various conditions and joins. The assignment includes placeholders for student identification and requires outputs to be shown in a shell format.

Uploaded by

Samir Rahman
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)
7 views7 pages

Samir Rahman Sec02 LAB03

The document contains a series of SQL queries related to a database assignment for a course on Database Systems. Each query retrieves specific information from a database involving customers, loans, accounts, and branches, with various conditions and joins. The assignment includes placeholders for student identification and requires outputs to be shown in a shell format.

Uploaded by

Samir Rahman
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
You are on page 1/ 7

CSE370 : Database Systems

Assignment 01/02/03 | Fall 2024


ID : <8 Digit Student ID> | Name : Full Official Name

No 1 Query SELECT customer.customer_name, borrower.loan_number


(as Plain Text) FROM customer
INNER JOIN borrower ON customer.customer_id = borrower.customer_id
INNER JOIN loan ON borrower.loan_number = loan.loan_number
WHERE loan.branch_name = 'Downtown';

No 1 SS
(of Query & Output
in Shell)

No 2 Query SELECT c1.customer_name AS Customer1, c2.customer_name AS Customer2, c1.customer_city AS City


(as Plain Text) FROM customer c1
INNER JOIN customer c2 ON c1.customer_city = c2.customer_city
WHERE c1.customer_id < c2.customer_id;
No 2 SS
(of Query & Output
in Shell)

No 3 Query SELECT branch.branch_name,


(as Plain Text) COALESCE(SUM(account.balance * 0.04), 0) AS Total_Interest
FROM branch
LEFT JOIN account ON branch.branch_name = account.branch_name
GROUP BY branch.branch_name;
No 3 SS
(of Query & Output
in Shell)

No 4 Query SELECT c.customer_city, a.account_number, a.balance


(as Plain Text) FROM account a
INNER JOIN depositor d ON a.account_number = d.account_number
INNER JOIN customer c ON d.customer_id = c.customer_id
WHERE a.balance = (
SELECT MAX(a2.balance)
FROM account a2
INNER JOIN depositor d2 ON a2.account_number = d2.account_number
INNER JOIN customer c2 ON d2.customer_id = c2.customer_id
WHERE c2.customer_city = c.customer_city
);

No 4 SS
(of Query & Output
in Shell)

No 5 Query SELECT loan.loan_number, loan.amount, customer.customer_name


(as Plain Text) FROM loan
INNER JOIN borrower ON loan.loan_number = borrower.loan_number
INNER JOIN customer ON borrower.customer_id = customer.customer_id
ORDER BY loan.amount DESC, loan.loan_number DESC
LIMIT 5;
No 5 SS
(of Query & Output
in Shell)

No 6 Query SELECT DISTINCT customer.customer_name


(as Plain Text) FROM customer
INNER JOIN depositor ON customer.customer_id = depositor.customer_id
INNER JOIN account ON depositor.account_number = account.account_number
INNER JOIN borrower ON customer.customer_id = borrower.customer_id
INNER JOIN loan ON borrower.loan_number = loan.loan_number
WHERE account.branch_name = 'Perryridge' AND loan.branch_name = 'Perryridge';
No 6 SS
(of Query & Output
in Shell)

No 7 Query SELECT customer.customer_name, SUM(loan.amount) AS Total_Loan


(as Plain Text) FROM customer
INNER JOIN borrower ON customer.customer_id = borrower.customer_id
INNER JOIN loan ON borrower.loan_number = loan.loan_number
GROUP BY customer.customer_name
HAVING COUNT(borrower.loan_number) >= 2;

No 7 SS
(of Query & Output
in Shell)

You might also like