0% found this document useful (0 votes)
22 views

CSE302_Lab03

DMRH LAB

Uploaded by

Shoeb Khandaker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

CSE302_Lab03

DMRH LAB

Uploaded by

Shoeb Khandaker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

East West University

Department of Computer Science and Engineering

CSE 302: LAB 03 (Handout)


Course Instructor: Dr. Mohammad Rezwanul Huq

Writing SQL Statements for Multi-table, Set and Aggregate queries

Lab Objective

Familiarize students with SQL statements involving multi-table, set and aggregate queries.

Lab Outcome

After completing this lab successfully, students will be able to:


1. Construct SQL statements to perform queries involving multi-table, set and aggregate queries.

Psychomotor Learning Levels

This lab involves activities that encompass the following learning levels in psychomotor domain.
Level Category Meaning Keywords
P2 Manipulation Reproduce activity Copy, response, trace, Show,
from instruction or Start, Perform, Execute,
memory Recreate.

Instructions

➢ Download and save banking script from https://goo.gl/o3r4Y2


➢ Suppose, you have saved it into the location f:\SQL\banking.sql
➢ Now execute the sql script file using @ command. @ f:\SQL\banking.sql
➢ The following tables along with data are created.

1) Branch (branch_name, branch_city, assets)


2) Customer (customer_name, customer_street, customer_city)
3) Account (account_number, branch_name, balance)
4) Loan (loan_number, branch_name, amount)
5) Depositor (customer_name, account_number)
6) Borrower (customer_name, loan_number)

Lab Discussions

• LIKE operator for String Matching


• DISTINCT keyword
• ARITHMETIC operation in SELECT clause
• CARTESIAN (CROSS) PRODUCT
• JOIN operator
o JOIN …. ON
o JOIN …. USING
• NATURAL JOIN operator
• ORDER BY clause
• SET OPERATIONS
o UNION
o INTERSECT
o MINUS
• AGGREGATE FUNCTIONS and GROUP BY clause
o AVG
o SUM
o MIN
o MAX
o COUNT
East West University
Department of Computer Science and Engineering

CSE 302: LAB 03 (Exercise - Offline)


Course Instructor: Dr. Mohammad Rezwanul Huq

You must write all SQL statements in notepad first and save them with .sql extension.
Then execute your SQL scripts.

Lab Tasks

1) Find all branch names and cities with assets more than 1000000. (on single table)
2) Find all account numbers and their balance which are opened in ‘Downtown’ branch or
which have balance in between 600 and 750. (on single table)
3) Find all account numbers which are opened in a branch located in ‘Rye’ city. (multiple
tables)
4) Find all loan numbers which have amount greater than or equal to 1000 and their customers
are living in ‘Harrison’ city. (multiple tables)
5) Display the account related information based on the descending order of the balance. (order
by clause)
6) Display the customer related information in alphabetic order of customer cities. (order by
clause)
7) Find all customer names who have an account as well as a loan. (intersect)
8) Find all customer related information who have an account or a loan. (union)
9) Find all customer names and their cities who have a loan but not an account. (minus)
10) Find the total assets of all branches. (aggregate function)
11) Find the average balance of accounts at each branch. (aggregate function)
12) Find the average balance of accounts at each branch city. (aggregate function)
13) Find the lowest amount of loan at each branch. (aggregate function)
14) Find the total number of loans at each branch. (aggregate function)
15) Find the customer name and account number of the account which has the highest balance.
(aggregate function)

Submission
Take screenshots of the execution and result of your queries in SQLPlus Tool and insert the captured image
in a doc file for each and every question . Submit both doc and sql file in the given submission link in the
Classroom. Submit files separately. Name the file as per the following format: 2022-1-60-001_LAB03.docx
and 2022-1-60-001.sql_LAB03.

You might also like