w3resource
SQL exercises

SQL Exercises: Display customer name, city, grade (according to the smallest ID)

SQL Formatting Output : Exercise-6 with Solution

Write a SQL statement to display the customer name, city, and grade and the display will be arranged according to the smallest customer ID.

Sample table: customer


Sample Solution:

SELECT cust_name,city,grade 
FROM customer 
ORDER BY customer_id;

Output of the Query:

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

Explanation :

Syntax of display the customer name, city and grade etc. and smallest customer ID will comes first

Pictorial presentation :

Result of display the customer name, city and grade etc. and smallest customer ID will comes first

Query Visualization:

Duration:

Query visualization of Display customer name, city, grade (according to the smallest ID) - Duration

Rows:

Query visualization of Display customer name, city, grade (according to the smallest ID) - Rows

Cost:

Query visualization of Display customer name, city, grade (according to the smallest ID) - Cost

 

Practice Online


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

Previous: Write a SQL statement to display the orders with all information in such a manner that, the older order date will come first and the highest purchase amount of same day will come first.
Next: 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.

What is the difficulty level of this exercise?



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