Consider the following table named Student in a relational database. The primary key of this table is rollNum. Student rollNum | name | gender | marks --------+-------+--------+------ 1 | Naman | M | 62 2 | Aliya | F | 70 3 | Aliya | F | 74 4 | Janum | M | 82 5 | Swati | F | 65 The SQL query below is executed on this database. SELECT * FROM Student WHERE gender = 'F' AND marks > 65; The number of rows returned by the query is ___________.

GATE 2023 · Databases · SQL · easy

Answer: 2 rows are returned by the query.

  1. Apply gender = 'F' filter: Row 1: Naman, M, 62 — FAIL (gender='M') Row 2: Aliya, F, 70 — PASS Row 3: Aliya, F, 74 — PASS Row 4: Janum, M, 82 — FAIL (gender='M') Row 5: Swati, F, 65 — PASS Rows passing first filter: {2, 3, 5}
  2. Apply marks > 65 filter to remaining rows: Row 2: Aliya, F, 70 — 70 > 65? YES — INCLUDED Row 3: Aliya, F, 74 — 74 > 65? YES — INCLUDED Row 5: Swati, F, 65 — 65 > 65? NO (equal, not greater) — EXCLUDED Rows in final result: {2, 3}