MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Where can subqueries be used? (Choose all that apply)
A
Field names in the SELECT statement
B
The FROM clause in the SELECT statement
C
The HAVING clause in the SELECT statement
D
The GROUP BY clause in the SELECT statement
E
The WHERE clause in SELECT as well as all DML statements
Explanation: 

Detailed explanation-1: -Subqueries can be used with SELECT, UPDATE, INSERT, DELETE statements along with expression operator. It could be equality operator or comparison operator such as =, >, =, <= and Like operator. A subquery is a query within another query. The outer query is called as main query and inner query is called as subquery.

Detailed explanation-2: -You can use subqueries in SELECT, INSERT, UPDATE, and DELETE statements wherever expressions are allowed. For instance, you can use a subquery as one of the column expressions in a SELECT list or as a table expression in the FROM clause. A DML statement that includes a subquery is referred to as the outer query.

Detailed explanation-3: -Answer: D. A subquery is a complete query nested in the SELECT, FROM, HAVING, or WHERE clause of another query.The subquery must be enclosed in parentheses and have a SELECT and a FROM clause, at a minimum.

Detailed explanation-4: -A subquery selects and returns values to the first or outer SELECT statement. A subquery can return no value, a single value, or a set of values, as follows: If a subquery returns no value, the query does not return any rows. Such a subquery is equivalent to a null value.

There is 1 question to complete.