Bird
0
0

You want to find all customers who placed orders with amounts greater than the average order amount. Which query correctly uses a nested subquery to achieve this?

hard📝 Application Q15 of 15
SQL - Subqueries
You want to find all customers who placed orders with amounts greater than the average order amount. Which query correctly uses a nested subquery to achieve this?
ASELECT customer_id FROM Orders WHERE amount < (SELECT AVG(amount) FROM Orders);
BSELECT customer_id FROM Orders WHERE amount = (SELECT AVG(amount) FROM Orders);
CSELECT customer_id FROM Orders WHERE amount > (SELECT AVG(amount) FROM Orders);
DSELECT customer_id FROM Orders WHERE amount IN (SELECT AVG(amount) FROM Orders);
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal

    We want customers with orders greater than the average order amount.
  2. Step 2: Analyze each option's condition

    SELECT customer_id FROM Orders WHERE amount > (SELECT AVG(amount) FROM Orders); uses > with a subquery calculating average amount, correctly filtering orders above average.
  3. Final Answer:

    SELECT customer_id FROM Orders WHERE amount > (SELECT AVG(amount) FROM Orders); -> Option C
  4. Quick Check:

    Use > with AVG subquery to find above-average orders [OK]
Quick Trick: Compare with (SELECT AVG(...)) using > for above average [OK]
Common Mistakes:
MISTAKES
  • Using = instead of > to find above average
  • Using < which finds below average
  • Using IN with a single value subquery incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes