Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVamsi Pavan Mahesh Gunturu
4,541 PointsHow does the following query works?
I have this query
select * from customers order by country
.. which I understood fine, because it will take into the account of the country attribute and gives the result in ascending order..
But how does the following one work
select * from customers order by country,id
how this would work?
1 Answer
Vince Brown
16,249 PointsHey Vamsi, For the SQL your data will be ordered twice, First the query will go through and order by country after that is completely through it will go back through and order by ID.
It might be easier to think of it like this if you have
SELECT * FROM products ORDER BY price, product_name
This query will go through and order all your products by price first, Then it comes back through and Orders all the subsets by name - So if any two products have the same price they would be ordered by product_name.
Hope this helps!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsChanged category to development tools