SQL Questions and Answers – SQL Any & All

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Any & All”.

1. ANY and ALL operators are used with which of the following clauses in SQL?
a) Where, select
b) Select, having
c) Where, having
d) Group by, where
View Answer

Answer: c
Explanation: The ANY and ALL operators are used with a WHERE or HAVING clause in SQL. ALL can be used with SELECT clause whereas ANY cannot be used with it. ANY and ALL cannot be used with GROUP BY.

2. ANY operator returns true if ______
a) any one of the subquery values doesn’t meet the condition
b) any one of the subquery values meets the condition
c) all the subquery values don’t meet the condition
d) all the subquery values meet the condition
View Answer

Answer: b
Explanation: ANY operator compares a value with the values in a list or results of a subquery and evaluates to true if the result of sub query contains at least one row.

3. ALL operator returns true if ______
a) All of the sub queries values satisfy the condition
b) All of the sub queries values doesn’t satisfies the condition
c) Any one of the sub queries values doesn’t satisfies the condition
d) Any one of the sub queries values satisfies the condition
View Answer

Answer: a
Explanation: ALL operator is used to compare a value to every value in another value set or result from a subquery. It returns true if all of the subquery values meet the condition.
advertisement
advertisement

4. ANY and ALL operators must be preceded by which of the following in SQL?
a) Arithmetic operators
b) Bitwise operators
c) Logical operators
d) Comparison operators
View Answer

Answer: d
Explanation: The ALL and ANY operators must be preceded by comparison operators like =, < >, !=, >, >=, <, <=.

5. What is the correct syntax for using ALL operator in SQL?
a)

SELECT column_list
FROM TABLE_NAME
WHERE column_name ALL (subquery);

b)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE column_name comparison_opearator ALL (subquery);

c)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE column_name NOT ALL (subquery);

d)

SELECT column_list
FROM TABLE_NAME
WHERE column_name ALL subquery;
View Answer
Answer: b
Explanation: Syntax for using ALL operator in SQL is:

SELECT column_list
FROM TABLE_NAME
WHERE column_name comparison_opeartor ALL (subquery);

6. If subquery of a query with ALL operator returns zero rows then the condition evaluates to be _______
a) Null
b) Undetermined
c) True
d) False
View Answer

Answer: c
Explanation: If a subquery of ALL operator returns zero rows, the condition evaluates to TRUE. If the subquery returns zero rows, it means the whole expression x > ALL (zero rows) evaluates to TRUE.

7. If a subquery of ANY operator returns zero rows then the condition evaluates to be _______
a) Null
b) True
c) False
d) Undetermined
View Answer

Answer: c
Explanation: If subquery of a query with ANY operator returns zero rows, the condition evaluates to FALSE. If the subquery returns zero rows, it means the whole expression x > ANY (zero rows) evaluates to FALSE.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.