Prinnie Boy Torregoza
PRO
last week
Prinniecountry asked

Why is this query wrong? SELECT * FROM Customers ORDER BY name ORDER BY country ORDER BY purchase_amount;

Abhay Jajodia
Expert
last week
Abhay Jajodia answered

Hello Prinnie! The issue is with your SQL statement is that you can't use multiple ORDER BY clauses in the same query.

Instead, you should separate the columns by commas within a single ORDER BY clause. For example, if you want to sort the results first by name, then by country, and finally by purchase_amount, you can do it like this:

SELECT *
FROM Customers
ORDER BY name, country, purchase_amount;

This way, all the sorting is done in one go, and you will get the results in the order you expect. Let me know if you have more questions!

Happy Coding!!!
SQL
This question was asked as part of the Learn SQL Basics course.