programming-examples/sql/Subqueries/8. Write a query to counts the customers with grades above New York's average.sql

7 lines
177 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
SELECT grade, COUNT (DISTINCT customer_id)
FROM customer
GROUP BY grade
HAVING grade >
(SELECT AVG(grade)
FROM customer
WHERE city = 'New York');