Bird
0
0

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

easy📝 Syntax Q12 of 15
SQL - Subqueries
Which of the following is the correct syntax for using a scalar subquery in the SELECT clause?
ASELECT name, SELECT MAX(score) FROM scores AS max_score FROM students;
BSELECT name, (SELECT MAX(score) FROM scores) AS max_score FROM students;
CSELECT name, MAX(score) FROM scores AS max_score FROM students;
DSELECT name, (MAX(score) FROM scores) AS max_score FROM students;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct scalar subquery syntax

    The scalar subquery must be enclosed in parentheses and used inside the SELECT clause.
  2. Step 2: Check each option

    SELECT name, (SELECT MAX(score) FROM scores) AS max_score FROM students; correctly uses parentheses around the subquery. Others miss parentheses or have wrong placement.
  3. Final Answer:

    SELECT name, (SELECT MAX(score) FROM scores) AS max_score FROM students; -> Option B
  4. Quick Check:

    Scalar subquery syntax = parentheses [OK]
Quick Trick: Always put scalar subquery inside parentheses in SELECT [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around subquery
  • Placing SELECT keyword incorrectly
  • Using aggregate functions without subquery

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes