w3resource
SQL exercises

SQL Exercises: Display customer name, city and grade by highest grade

SQL Formatting Output: Exercise-8 with Solution

Write a SQL statement to display customer name, city and grade in such a manner that, the customer holding highest grade will come first.

Sample table: customer


Sample Solution:

SELECT cust_name,city,grade 
FROM customer 
ORDER BY 3 DESC;

Output of the Query:

cust_name	city		grade
Brad Guzan	London	
Fabian Johnson	Paris		300
Julian Green	London		300
Brad Davis	New York	200
Jozy Altidor	Moscow		200
Graham Zusi	California	200
Nick Rimando	New York	100
Geoff Cameron	Berlin		100

Explanation:

Syntax of display customer name, city and grade in such a manner that, the customer holding highest grade will comes first

Pictorial presentation :

Result of display customer name, city and grade in such a manner that, the customer holding highest grade will comes first

Query Visualization:

Duration:

Query visualization of Display customer name, city and grade by highest grade - Duration

Rows:

Query visualization of Display customer name, city and grade by highest grade - Rows

Cost:

Query visualization of Display customer name, city and grade by highest grade - Cost

 

Practice Online


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

Previous: Write a SQL statement to make a report with salesman ID, order date and highest purchase amount in such an arrangement that, the smallest salesman ID will come first along with their smallest order date.
Next: Write a SQL statement to make a report with customer ID in such a manner that, the largest number of orders booked by the customer will come first along with their highest purchase amount.

What is the difficulty level of this exercise?



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