SQL Exercise: Display customer name, city, grade
SQL Formatting Output: Exercise-6 with Solution
From the following table, write a SQL query to find all the customers. Sort the result-set by customer_id. Return cust_name, city, grade.
Sample table: customer
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
The said query in SQL retrieves data from the 'customer' table and returns the columns cust_name, city, and grade.
The "ORDER BY customer_id" clause sorts the rows in the result set based on the values in the customer_id column.
Relational Algebra Expression:
Relational Algebra Tree:
Visual presentation :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: Oldest orders first on the highest purchase amount.
Next SQL Exercise: Salesman details by smallest ID along with order date.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join