GATE / CS ARCHIVE

GATE CSE 2023 / QUESTION 61

GATE CSE 2023 Q61

Database Management Systems · SQL & Queries · Full GATE CSE 2023 paper

GATE 2023, Q61 2 marks · NAT
Report issue

SQL & Queries

Question 61, GATE 2023: Student rows (rollNum,name,gender,marks) are (1,Naman,M,62),(2,Aliya,F,70),(3,Aliya,F,80),(4,James,M,82),(5,Swati,F,65); rollNum is primary key. How many rows does SELECT * FROM Student WHERE gender='F' AND marks>65 return?
Tap to enlarge
Answer & solution

Official answer: 2

The condition requires both female gender and marks strictly greater than 65. Roll numbers 2 and 3 qualify, with marks 70 and 80. Swati has exactly 65 and is excluded; the other two rows are male. The two Aliya rows remain distinct because their roll numbers differ, and SELECT * does not deduplicate them. The result contains 2 rows.

Teaching detail. Evaluate the conjunction row by row: row 1 fails gender, row 2 passes both predicates, row 3 passes both, row 4 fails gender despite high marks, and row 5 fails the strict greater-than test. The primary key identifies records by rollNum, not by name, so equal names do not imply one record. SQL's ordinary SELECT is not SELECT DISTINCT; moreover even DISTINCT over all columns would keep the two qualifying rows because both roll numbers and marks differ. Only the number of qualifying rows is requested.

Original paper, page 64 · Answer key