🗄️ SQL
Why it matters: Output-of-a-query questions are the most frequent database marks. Know the evaluation order, aggregates with NULL, and nested queries.
Subtopics
Each subtopic has its own page: idea, why, how, example, play, check. Mark each one understood when it clicks. 0 of 5 done.
Formulas
What GATE asks from this
Question types seen repeatedly in past papers. More stars means more frequent.
Ratings are approximate, based on recurring patterns in past GATE CSE papers.
Previous year questions
13 real questions from the official GATE CSE papers (2011 to 2025), newest first, each with the official answer key and a worked solution. Questions are the property of the GATE organising institutes; this copy is for your personal study.
13 questions · 0 correct of 0 attempted · marks 0 / 22
SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno)(B) the same with WHERE SIZEOF(
SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno) > 0(C) the same with WHERE 0 < (
SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno)(D)
SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470
One or more options may be correct. Select all that apply, then submit.
player = (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30); coach = (101, Ricky), (102, Mark), (103, Trevor); team = (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103);members = (1, 10), (2, 30), (3, 10), (4, 20). Query:
SELECT MIN(P.age) FROM player P WHERE P.pid IN (SELECT M.pid FROM team T, coach C, members M WHERE C.cname = 'Mark' AND T.cid = C.cid AND M.tid = T.tid)The value returned is ______.
SELECT * FROM Student WHERE gender = 'F' AND marks > 65is executed. The number of rows returned by the query is ______.
SELECT * FROM Student AS S WHERE NOT EXISTS (SELECT cNo FROM Course WHERE dNo = "D01" EXCEPT SELECT cNo FROM Register WHERE sNo = S.sNo)The number of rows returned by the above SQL query is ______.
SELECT s.sno, s.sname FROM Suppliers s, Catalogue c WHERE s.sno = c.sno AND cost > (SELECT AVG(cost) FROM Catalogue WHERE pno = 'P4' GROUP BY pno)The number of rows returned by the above SQL query is
SELECT S.Student_name, sum(P.Marks) FROM Student S, Performance P WHERE P.Marks > 84 GROUP BY S.Student_nameThe number of rows returned by the above SQL query is ______.
SELECT B.isbn, S.copies FROM Book B INNER JOIN Stock S ON B.isbn = S.isbnQuery 2: the same with LEFT OUTER JOIN; Query 3: the same with RIGHT OUTER JOIN; Query 4: the same with FULL OUTER JOIN. Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
SELECT AVG(EC.Num) FROM EC WHERE (DeptName, Num) IN (SELECT DeptName, COUNT(EmpId) AS EC(DeptName, Num) FROM EMP GROUP BY DeptName)The output of executing the SQL query is ______.
SELECT last-name, hire-date FROM employees WHERE (dept-id, hire-date) IN (SELECT dept-id, MAX(hire-date) FROM employees JOIN departments USING(dept-id) WHERE location-id = 1700 GROUP BY dept-id)What is the outcome?
SELECT A.Id FROM A WHERE A.Age > ALL (SELECT B.Age FROM B WHERE B.Name = 'Arun')
SELECT count(*) FROM ((SELECT Borrower, Bank_Manager FROM Loan_Records) AS S NATURAL JOIN (SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T)