Bird
0
0

What is the primary reason to use subqueries in SQL?

easy📝 Conceptual Q1 of 15
SQL - Subqueries
What is the primary reason to use subqueries in SQL?
SELECT employee_id FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
ATo join two tables without specifying join conditions
BTo filter results based on a dynamically calculated value
CTo permanently store intermediate results in a table
DTo create indexes on columns automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query

    The query filters employees whose salary is greater than the average salary.
  2. Step 2: Role of subquery

    The subquery calculates the average salary dynamically.
  3. Final Answer:

    To filter results based on a dynamically calculated value -> Option B
  4. Quick Check:

    Subqueries allow filtering using computed values [OK]
Quick Trick: Subqueries compute values for filtering [OK]
Common Mistakes:
MISTAKES
  • Thinking subqueries are used for joins only
  • Assuming subqueries create permanent tables
  • Confusing subqueries with indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes