SQL Subquery Exercises: Counts the customers with grades above New York's average
SQL SUBQUERY : Exercise-8 with Solution
8. Write a query to count the customers with grades above New York's average.
Sample table: Customer
SELECT grade, COUNT (DISTINCT customer_id) FROM customer GROUP BY grade HAVING grade > (SELECT AVG(grade) FROM customer WHERE city = 'New York');
grade count 200 3 300 2
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?