Consider the following table named in a relational database. The primary key of this table is
The 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 ___________.
View worked solution
Answer: 2
To find the number of rows returned by the SQL query, we evaluate the condition in the WHERE clause for each row in the Student table:
Let's check each row individually:
- rollNum 1 (Naman):
gender = 'M'(False). The condition fails. - rollNum 2 (Aliya):
gender = 'F'(True) andmarks = 70 > 65(True). The condition is True. - rollNum 3 (Aliya):
gender = 'F'(True) andmarks = 80 > 65(True). The condition is True. - rollNum 4 (James):
gender = 'M'(False). The condition fails. - rollNum 5 (Swati):
gender = 'F'(True) butmarks = 65 > 65is False (since is not strictly greater than ). The condition fails.
The rows with rollNum 2 and 3 satisfy the query condition.
Thus, the number of rows returned by the query is 2.
Free practice · Your answers on this page are not saved.
