Scenario - Based - Que - Dbms
Scenario - Based - Que - Dbms
1st Que
Consider the below relational database where primary keys are
3. Find name of all employee who do not work for first bank corporation.
4. Find name of all employee who work for first bank corporation
5. Find name, street, city of all employee who work for first bank Corporation
6. Find names of all emp who live in same city as that of their Company.
SQLCopy code
SELECT Ename
FROM Employee
SQLCopy code
SELECT Ename
FROM Employee
1. To find name of all employee who do not work for first bank corporation:
SQLCopy code
SELECT Ename
FROM Employee
WHERE Eid NOT IN (SELECT Eid FROM Works WHERE Cid = (SELECT Cid FROM Company
WHERE Cname = 'first bank corporation'));
1. To find name of all employee who work for first bank corporation:
SQLCopy code
SELECT Ename
FROM Employee
WHERE Eid IN (SELECT Eid FROM Works WHERE Cid = (SELECT Cid FROM Company WHERE
Cname = 'first bank corporation'));
1. To find name, street, city of all employee who work for first bank Corporation and earn
more than 10,000:
SQLCopy code
FROM Employee
1. To find names of all emp who live in same city as that of their Company:
SQLCopy code
SELECT Employee.Ename
FROM Employee
2 nd Que
Consider following schema & answer following queryCustomer(cname,street,city)
Deposit(cname,accno)Loan(loanno,bname,amt)Borrow(cname,loanno)1. Find customer
name who lives in Nagpur2. Find all customer name having loan amount less than 20000 of
branch SBI3. Find names of customer having either account or loan or both4. Find all
customer having loan at bank5. Find all customers who have loan but no loan at bank6. Find
all city names containing character n 7. Find all branch names whose names are not ending
with a8. Find number of customers of bank SBI9. Find lowest amount of loan at bank with
name AXIS.10. Find customer name having loan amt > 50000
SQLCopy code
SELECT cname
FROM Customer
1. To find all customer name having loan amount less than 20000 of branch SBI:
SQLCopy code
FROM Customer
SQLCopy code
SQLCopy code
FROM Customer
INNER JOIN Borrow ON Customer.cname = Borrow.cname;
SQLCopy code
FROM Customer
SQLCopy code
FROM Customer
1. To find all branch names whose names are not ending with a:
SQLCopy code
FROM Loan
SQLCopy code
FROM Customer
SQLCopy code
SELECT MIN(amt)
FROM Loan
SQLCopy code
FROM Customer
3rd que
Consider below schema and Construct SQL Query for below problem statements.
1. Find names of sailors who have reserved a Red and Green boat.
3. Find sailor id of all sailors who have reserve Red boat but not green
7. Find name of sailor whose name starts with a and age > 60.
8. Find name and id of the sailor who have reserve boat on 1-4-2014.
10. Find name of sailor who have reserve boat on 5-5-2013 and bname start from I.
1. To find names of sailors who have reserved a Red and Green boat:
SQLCopy code
FROM Sailor
SQLCopy code
FROM Sailor
1. To find sailor id of all sailors who have reserve Red boat but not green:
SQLCopy code
FROM Sailor
(SELECT Sailor.Sid
FROM Sailor
SQLCopy code
SELECT DISTINCT Sailor.Sname
FROM Sailor
SQLCopy code
SELECT Boat.color
FROM Sailor
SQLCopy code
SELECT Sailor.Sname
FROM Sailor
1. To find name of sailor whose name starts with a and age > 60:
SQLCopy code
SELECT Sailor.Sname
FROM Sailor
1. To find name and id of the sailor who have reserve boat on 1-4-2014:
SQLCopy code
FROM Sailor
SQLCopy code
SELECT Boat.bname
FROM Reserve
1. To find name of sailor who have reserve boat on 5-5-2013 and bname start from I:
SQLCopy code
SELECT Sailor.Sname
FROM Sailor