Sample Question On SQL
Sample Question On SQL
Q. 1: Write SQL expression to find Sid, F-NID, M-NID, mobile, email and age of all
students whose tot-cred is greater than or equal to 130.
Q. 2: Write SQL expression to find F-NID, Sid, course-id and title for all students whose
parents live in Dhaka.
Q. 3: Write SQL expression to find Sid, name, street, city and average grade of each
student.
Q. 4: Find city and street wise average, maximum and minimum income of parents (of
students) living in Dhaka or Rajshahi and average income higher than 500000.
Q. 5: Write SQL expression to find Sid, name, course-id and title of all students who have
taken any course (course-id) taken by Abid in Fall 2018.
Q. 6: Write SQL expression to find Sid, name, course-id and title of all students who have
taken all courses taken by Abid in Fall 2018.
Q. 8. Some students have become teachers. Write SQL statement to insert id, name, street,
city, mobile and email into teacher table. Other attributes will be null.
a. Insert all the loans of branch name = “NSU” to the account relation as loan number will
be account number and amount will be balance.
b. Update the database as follows: those borrower have loans more than 50000, decrease
their loan by 10%. For other borrowers, make their loan zero.
c. Delete all loans of customers who lives in ‘Gazipur’.
d. Find the list of customer name, branch name and branch city of all customers who lives
in ‘Dhaka’.
e. Find the list of customer name, branch name and branch city of all customers who have
accounts in all branch city.
f. There are some customers who have no account and also some customers who have no
loan. Find these customer name, customer street and customer city for the above using
joins.
Q12: Using the relational schema of Q3, there are some employees who do not work to 6
any company. Create a view named employee-no-company with only those employees not
working to any company.
Find each customer city and the total amount of loan of that customer city. Output:
customer city, loan-amount.
Find person-name and company-name of all employees who live in the same city where
‘Abid’ lives.