w3resource
SQL exercises

SQL Exercises: Find the highest grade for each of the cities of the customers

SQL Aggregate Functions: Exercise-8 with Solution

Write a SQL statement which selects the highest grade for each of the cities of the customers.

Sample table: customer


Sample Solution:

SELECT city,MAX(grade) 
FROM customer 
GROUP BY city;

Output of the Query:

city		max
London		300
Paris		300
New York	200
California	200
Berlin		100
Moscow		200

Explanation:

Syntax of find the highest grade for each of the cities of the customers

Pictorial presentation :

Find the highest grade for each of the cities of the customers

Query Visualization:

Duration:

Query visualization of Find the highest grade for each of the cities of the customers - Duration

Rows:

Query visualization of Find the highest grade for each of the cities of the customers - Rows

Cost:

Query visualization of Find the highest grade for each of the cities of the customers - Cost

 

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a SQL statement to know the maximum purchase amount of all the orders.
Next: Write a SQL statement to find the highest purchase amount ordered by the each customer with their ID and highest purchase amount.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming