edited by
11,429 views
40 votes
40 votes

Consider the following relation

Cinema($\textit{theater, address, capacity}$)

Which of the following options will be needed at the end of the SQL query

SELECT P1.address
FROM Cinema P1

such that it always finds the addresses of theaters with maximum capacity?

  1. WHERE P1.capacity >= All (select P2.capacity from Cinema P2)
  2. WHERE P1.capacity >= Any (select P2.capacity from Cinema P2)
  3. WHERE P1.capacity > All (select max(P2.capacity) from Cinema P2)
  4. WHERE P1.capacity > Any (select max(P2.capacity) from Cinema P2)
edited by

3 Answers

Best answer
73 votes
73 votes
A is the answer

B - Returns the addresses of all theaters.
C - Returns null set. max() returns a single value and there won't be any value > max.
D - Returns null set. Same reason as C. All and ANY works the same here as max returns a single value.
edited by
6 votes
6 votes
Answer is A.

Inner query collects capacities of all the theatres and in outer query we are filtering the tuples with the condition  " p1.capacity>=All". So the theatre which is having maximum capacity will be satisfy the condition.
2 votes
2 votes

(A) : Inner query collects capacities of all the theatres and in outer query we are filtering the tuples 
with the condition “capacity>=All”. So the theatres which are having maximum capacity will 
be satisfy the conductivity and they will.

(B) : Returns all the rows as ANY is used

(C)  & (D): Returns no rows as nothing can be greater than all or any of the maximum values
Answer:

Related questions

51 votes
51 votes
4 answers
1