This document provides the schema for a database management system (DBMS) lab assignment and includes 21 queries to be answered using the given schema. It also includes 7 additional queries to explain the meaning of. The queries cover topics such as displaying customer, account, branch, and other data; joins between tables; aggregation of data by city, branch, and other attributes; sorting results; and more.
This document provides the schema for a database management system (DBMS) lab assignment and includes 21 queries to be answered using the given schema. It also includes 7 additional queries to explain the meaning of. The queries cover topics such as displaying customer, account, branch, and other data; joins between tables; aggregation of data by city, branch, and other attributes; sorting results; and more.
Using the schema given above, answer the following queries.
1. Display names of the customers who have account in the city where they live. 2. Display details of customers who are not borrower. 3. Display customer details who have taken loan more than 3 times. 4. Display pairs of customers who live in the same city. 5. Display details of the customers whose name is the longest. 6. Display details of borrowers who have taken loan from 'Ahmedabad' branch. 7. Display details of borrowers who have taken total loan of more than Rs. 50,00,000. 8. Display total assets of all the branches. 9. Display details of customers who are depositors. 10. Display left outer join of customer and depositor table. 11. Display right outer join of account and depositor table. 12. Display account number in which balance is minimum. 13. Display account number in which balance is second highest. 14. Display branch name, branch city, account number, customer name and customer city in ascending order of customer city and descending order of branch city. 15. Display total no. of customers in each city. 16. Display city wise total assets in descending order of total assets. 17. Display borrower names with total loan amount taken. 18. Display details of the customers who are depositors as well as borrower. 19. Display inner join of customer, borrower, loan and branch. 20. Display union of branch and account. (Use “union” operator) 21. Display intersection of branch and account. ((Use “intersect” operator)
Explain meaning of following queries. (If any error, rewrite with correction and meaning)
1. select d1.doc_name from doctor d1,doctor d2 where d1.gender<>d2.gender and
d1.doc_id<>d2.doc_id and d1.doc_name=d2.doc_name; 2. select empname, salary from employee where salary=(select max(salary) from employee where salary<(select max(salary) from employee)); 3. select deptname from department group by deptnname having count(empid)>100 order by count(empid) desc; 4. select stdname,marks1,marks2,marks3,marks4,marks5 from student where ((marks1+marks2+marks3+marks4+marks5)*100/250)=(select max(((marks1+marks2+marks3+marks4+marks5)*100/250)) from student); 5. select * from result where (classid,stdno) in (select classid,stdno from student where classcode in (select classcode from class where roomno in (select roomno from room))); 6. select deptname from salary group by deptname having sum(salary)=(select m1.max_sal from (select max(m.sal) max_sal from (select deptname, sum(salary) as sal from salary group by deptname) m) m1); 7. select deptname,sum(salary) from salary group by deptname having sum(salary)=(select m1.max_sal from (select max(m.sal) max_sal from (select deptname, sum(salary) as sal from salary group by deptname) m) m1);