edited by
16,032 views
44 votes
44 votes

Consider the following database table named $\text{top_scorer}$.

$$\overset{\text{top_scorer}}{\begin{array}{|c|c|c|}\hline\\
\textbf{player}&    \textbf{country}&  \textbf{goals} \\\hline
\text{Klose}&      \text{Germany}&    16\\ \hline   
\text{Ronaldo}&     \text{Brazil}& 15 \\     \hline
\text{G Muller}&     \text{Germany}&  14     \\\hline
\text{Fontaine}&     \text{France}& 13    \\\hline
\text{Pele}&     \text{Brazil}&     12 \\\hline    
\text{Klinsmann}&     \text{Germany}& 11   \\\hline   
\text{Kocsis}&     \text{Hungary}&  11      \\\hline 
\text{Batistuta}&     \text{Argentina}&10      \\\hline 
\text{Cubillas}&     \text{Peru}&10     \\\hline 
\text{Lato}&     \text{Poland}&  10 \\\hline \text{Lineker}&     \text{England}& 10       \\\hline 
\text{T Muller}&     \text{Germany}&  10      \\\hline 
\text{Rahn}&     \text{Germany}& 10 \\\hline 
\end{array}}$$

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 tb.country = 'Spain')
AND ta.goals > ANY (SELECT tc.goals
    FROM top_scorer AS tc
    WHERE tc.country='Germany')

The number of tuples returned by the above SQL query is ______

edited by

3 Answers

Best answer
64 votes
64 votes

ALL (EMPTY SET) always returns TRUE. So first where condition is always satisfied. 

Second where condition will return all those rows who have more goals than ANY German player. Since, minimum goals by a German is $10$, all the rows which are greater than $10$ Goals will be returned. 

I.e. first $7$ rows in the table. 

Hence, answer: 7.

edited by
12 votes
12 votes

Ans)7

1.Select players which have goals greter than all players of spain and at least one player of germany.

2.No spain player so,first condition is always true,as universal quantifier is always true over empty domain.

3.For second condition,least goal of germany is 10 and number of players having goals strictly greater than 10 are first 7.

11 votes
11 votes
The players having goals greater than least goals i.e. 10 are selected So answer is 7 (hope so).
Answer:

Related questions

31 votes
31 votes
5 answers
2
Madhav asked Feb 14, 2017
10,827 views
In a B+ Tree , if the search-key value is $8$ bytes long , the block size is $512$ bytes and the pointer size is $2\;\text{B}$ , then the maximum order of the B+ Tree is ...
62 votes
62 votes
6 answers
3
Madhav asked Feb 14, 2017
18,239 views
Consider the following tables $T1$ and $T2.$$$\overset{T1}{\begin{array}{|c|c|c|} \hline \textbf {P} & \textbf {Q} \\\hline \text {2} & \text{2 }\\\hline \text{3} & \te...