Skip to main content

GATE CSE 2023Databases › SQLVerified

GATE CSE 2023 PYQ: Consider the following table named Student \text{Student} Student in a relational database. The primary key…

Consider the following table named Student\text{Student} in a relational database. The primary key of this table is rollNum.\text{rollNum}.

Student\text{Student}
rollNum‾namegendermarks1NamanM622AliyaF703AliyaF804JamesM825SwatiF65\begin{array}{|c|l|c|c|} \hline \underline{\text{rollNum}} & \text{name} & \text{gender} & \text{marks} \\ \hline \hline 1 & \text{Naman} & \mathrm{M} & 62 \\ \hline 2 & \text{Aliya} & \mathrm{F} & 70 \\ \hline 3 & \text{Aliya} & \mathrm{F} & 80 \\ \hline 4 & \text{James} & \mathrm{M} & 82 \\ \hline 5 & \text{Swati} & \mathrm{F} & 65 \\ \hline \end{array}

The SQL\text{SQL} query below is executed on this database.

  1. SELECT *
  2. FROM Student
  3. WHERE gender = 'F' AND
  4. marks > 65;

The number of rows returned by the query is ___________.

    Answer

    2

    Approach

    Apply the SQL WHERE clause conditions using AND: keep only rows where gender = 'F' and marks > 65, then count the remaining rows.

    Only two records satisfy both conditions: Aliya with rollNum 2 and marks 70, and Aliya with rollNum 3 and marks 80. Swati has gender F but marks exactly 65, which fails marks > 65.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.