GATE CS 2019 · SQL Queries

NAT · 2 marks · Problem DBMS-SQL-0065

A relational database contains two tables Student and Performance as shown below:\[\begin{array}{cc} \textbf{Student} & \textbf{Performance} \\ \begin{array}{|c|c|} \hline \text{Roll\_no.} & \text{Student\_name} \\ \hline 1 & \text{Amit} \\ 2 & \text{Priya} \\ 3 & \text{Vinit} \\ 4 & \text{Rohan} \\ 5 & \text{Smita} \\ \hline \end{array} & \begin{array}{|c|c|c|} \hline \text{Roll\_no.} & \text{Subject\_code} & \text{Marks} \\ \hline 1 & A & 86 \\ 1 & B & 95 \\ 1 & C & 90 \\ 2 & A & 89 \\ 2 & C & 92 \\ 3 & C & 80 \\ \hline \end{array} \end{array}\]The primary key of the Student table is Roll_no. For the Performance table, the columns Roll_no. and Subject_code together form the primary key. Consider the SQL query given below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;
The number of rows returned by the above SQL query is

Numerical answer (NAT).

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{\text{no join condition} \Rightarrow \text{Student} \times \text{Performance}}\]The WHERE clause only filters marks: 5 Performance rows have Marks \(> 84\), and each is paired with every student.So every one of the 5 distinct student names survives, and GROUP BY Student_name gives one row per name.Answer: 5

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com