SQL: GATE DA Previous Year Questions

SQL · Database Management and Warehousing

4 questions · asked in 3 of 3 years (2024–2026)

MSQ 1 · NAT 31-mark 2 · 2-mark 2

2024Questions per year2026

Questions 1–4 of 4

Q1GATE 20262 marksMSQ
Consider a table Employee(EmpID, TeamID), where the column EmpID (ID of an employee) is the primary key. The column TeamID denotes the team ID of the team of which the employee is a member. TeamID is a NOT NULL column.

We want to display the size of the team (denoted as TeamSize) in which each employee is a member by using SQL. As an example, the desired output for the given Employee table is also shown in tabular form.

Which of the following is/are correct?

Employee\textbf{Employee}
EmpIDTeamID182838475769\begin{array}{|c|c|} \hline \text{EmpID} & \text{TeamID} \\ \hline 1 & 8 \\ \hline 2 & 8 \\ \hline 3 & 8 \\ \hline 4 & 7 \\ \hline 5 & 7 \\ \hline 6 & 9 \\ \hline \end{array}

Output\textbf{Output}
EmpIDTeamSize132333425261\begin{array}{|c|c|} \hline \text{EmpID} & \text{TeamSize} \\ \hline 1 & 3 \\ \hline 2 & 3 \\ \hline 3 & 3 \\ \hline 4 & 2 \\ \hline 5 & 2 \\ \hline 6 & 1 \\ \hline \end{array}

One or more options are correct.

Q2GATE 20262 marksNAT
Let Account be a relation as shown.

Account\textbf{Account}
AccNoBalanceA15000A25000A310000A415000A518000\begin{array}{|c|c|} \hline \text{AccNo} & \text{Balance} \\ \hline \text{A1} & 5000 \\ \hline \text{A2} & 5000 \\ \hline \text{A3} & 10000 \\ \hline \text{A4} & 15000 \\ \hline \text{A5} & 18000 \\ \hline \end{array}

Consider the given SQL query.
SELECT AccNo FROM Account AS A
  WHERE (SELECT COUNT(*) FROM Account AS B
  WHERE A.Balance < B.Balance) >= (SELECT COUNT(*)
  FROM Account AS C WHERE A.Balance > C.Balance) 
The number of rows returned by the SQL query is ________. (Answer in integer)

Q3GATE 20251 markNAT
On a relation named Loan of a bank:

Loanloan numberbranch nameamountL11Banjara Hills90000L14Kondapur50000L15SR Nagar40000L22SR Nagar25000L23Balanagar80000L25Kondapur70000L19SR Nagar65000\begin{array}{c} \textbf{Loan}\\ \begin{array}{|c|c|c|} \hline \text{loan number} & \text{branch name} & \text{amount} \\ \hline L11 & \text{Banjara Hills} & 90000 \\ \hline L14 & \text{Kondapur} & 50000 \\ \hline L15 & \text{SR Nagar} & 40000 \\ \hline L22 & \text{SR Nagar} & 25000 \\ \hline L23 & \text{Balanagar} & 80000 \\ \hline L25 & \text{Kondapur} & 70000 \\ \hline L19 & \text{SR Nagar} & 65000 \\ \hline \end{array}\end{array}

The following SQL query is executed:

SELECT L1.loan number
 FROM Loan L1
 WHERE L1.amount >(SELECT MAX(L2.amount)
 FROM Loan L2
 WHERE L2.branch name='SR Nagar'); 

The number of rows returned by the query is _______(Answer in integer)

Q4GATE 20241 markNAT
Consider the following two tables named Raider and Team in a relational database maintained by a Kabaddi league. The attribute ID in table Team references the primary key of the Raider table, ID.

RaiderIDNameRaidsRaidPoints1Arjun2002502Ankush1902193Sunil1502004Reza1501905Pratham1752206Gopal193215\begin{array}{c} \textbf{Raider} \\ \begin{array}{|l|l|l|l|} \hline ID & Name & Raids & RaidPoints \\ \hline 1 & Arjun & 200 & 250 \\ \hline 2 & Ankush & 190 & 219 \\ \hline 3 & Sunil & 150 & 200 \\ \hline 4 & Reza & 150 & 190 \\ \hline 5 & Pratham & 175 & 220\\ \hline 6 & Gopal & 193 & 215 \\ \hline\end{array} \end{array}

TeamCityIDBidPointsJaipur2200Patna3195Hyderabad5175Jaipur1250Patna4200Jaipur6200\begin{array}{c} \textbf{Team} \\ \begin{array}{|l|l|l|} \hline City & ID & BidPoints\\ \hline Jaipur & 2 & 200 \\ \hline Patna & 3 & 195 \\ \hline Hyderabad & 5 & 175 \\ \hline Jaipur & 1 & 250 \\ \hline Patna & 4 & 200 \\ \hline Jaipur & 6 & 200 \\ \hline \end{array}\end{array}

The SQL query described below is executed on this database:
SELECT * 
FROM Raider, Team 
WHERE Raider.ID=Team.ID AND City=“Jaipur” AND 
RaidPoints > 200; 
The number of rows returned by this query is _________ .

Keep practising

Topics in Database Management and Warehousing

All DA topics ›