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
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
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
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.
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
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)
SELECT column_list FROM TABLE_NAME WHERE column_name comparison_opearator ALL (subquery);
c)
SELECT column_list FROM TABLE_NAME WHERE column_name NOT ALL (subquery);
d)
SELECT column_list FROM TABLE_NAME WHERE column_name ALL subquery;
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
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
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]