Bird
0
0

Which of the following is the correct syntax for a scalar subquery in the SELECT clause?

easy📝 Syntax Q3 of 15
SQL - Subqueries
Which of the following is the correct syntax for a scalar subquery in the SELECT clause?
ASELECT col1, (SELECT MAX(col2) FROM table2) AS max_val FROM table1;
BSELECT col1 FROM table1 WHERE (SELECT col2 FROM table2);
CSELECT col1, SELECT MAX(col2) FROM table2 FROM table1;
DSELECT col1, MAX(col2) FROM table1, table2;
Step-by-Step Solution
Solution:
  1. Step 1: Review scalar subquery syntax

    Scalar subquery is enclosed in parentheses and used as a column expression.
  2. Step 2: Check each option

    SELECT col1, (SELECT MAX(col2) FROM table2) AS max_val FROM table1; correctly uses parentheses and alias for scalar subquery in SELECT.
  3. Final Answer:

    SELECT col1, (SELECT MAX(col2) FROM table2) AS max_val FROM table1; -> Option A
  4. Quick Check:

    Correct scalar subquery syntax = SELECT col1, (SELECT MAX(col2) FROM table2) AS max_val FROM table1; [OK]
Quick Trick: Scalar subquery must be in parentheses in SELECT [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around subquery
  • Using subquery outside SELECT clause incorrectly
  • Missing alias for scalar subquery column

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes