GATE | GATE-CS-2017 (Set 2) | Question 61

Consider the following database table named top_scorer.


Consider the following SQL query:

SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL ( SELECT tb.goals
		       FROM top_scorer AS tb
		       WHERE = 'Spain' )
      AND ta.goals > ANY (SELECT tc.goals
	       	        FROM top_scorer AS tc
		        WHERE = 'Germany')

The number of tuples returned by the above SQL query is ____.

Note: This questions appeared as Numerical Answer Type.
(A) 6
(B) 7
(C) 8
(D) 9

Answer: (B)


The query says we need to

      1. Condition 1: Select players which have goals greater than ALL players of spain – This conditon will always be true as ALL (empty) always returns TRUE.
      2. Condition 2: Any  player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.

Looking at the table, first 7 rows satisfy both the conditions.goals

Therefore, option B is true.

Quiz of this Question

My Personal Notes arrow_drop_up