Queries From QP
Queries From QP
(i) Retrieve the names of all students enrolled for the course 'CS_54':
SELECT S.NAME
FROM Student S
OR
SELECT S.NAME
(ii) List all the departments having an average salary of the faculties above Rs.
10,000:
SELECT DEPARTMENT
FROM Faculty
GROUP BY DEPARTMENT
HAVING AVG(SALARY) > 10000;
(iii) List the names of the students enrolled for the course 'CS_51' and having 'B' grade:
SELECT S.NAME
FROM Student S
OR
SELECT S.NAME
Schema:
SELECT *
FROM Flight
(ii) Find only the flight numbers for passenger with pid 123 for flights to Chennai before
06/11/2020:
SELECT F.fid
FROM Flight F
WHERE B.pid = 123 AND F.dest = 'Chennai' AND F.fdate < '2020-11-06';
OR
SELECT F.fid
AND B.pid = 123 AND F.dest = 'Chennai' AND F.fdate < '2020-11-06';
(iii) Find the passenger names for those who do not have any bookings in any flights:
SELECT pname
FROM Passenger
iv) Get the details of flights that are scheduled on both dates 01/12/2020 and 02/12/2020 at 16:00
hours:
SELECT *
FROM Flight F1
AND EXISTS (
SELECT *
FROM Flight F2
);
(v) Find the details of all male passengers who are associated with Jet agency:
SELECT P.*
FROM Passenger P
OR
SELECT P.*
Schema:
i) List the names of the people who work for the Company 'Wipro' along with the cities they live
in:
FROM Works W
OR
SELECT W.Pname, L.City
(ii) Find the names of the persons who do not work for 'Infosys':
FROM Works
SELECT Pname
FROM Works
);
(iii) Find the people whose salaries are more than that of all the 'Oracle' employees:
SELECT Pname
FROM Works
SELECT Salary
FROM Works
);
(iv) Find the persons who work and live in the same city:
SELECT W.Pname
FROM Works W
OR
SELECT W.Pname
(v) Find the names of the companies that are located in every city where the Company Infosys is
located:
SELECT City
FROM LocatedIn
EXCEPT
SELECT City
);