We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
basically with the ORDER BY clause you can sort by multiple things, not just one. So in this example,
when the following code is executed:
ORDER BY LEN(CITY), CITY
you are first ordering by LEN(CITY) meaning that the query will order the results by the length of the city name.
So all of the city names with 3 letters, then 4, then 5, and so on....
But, this is all it does, and it will not order them any other way because you did not explicity say to do so. So now the length of the city name is sorted in ascending order, but the results are not alphabetical. This is where the ,CITY part comes in.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 5
You are viewing a single comment's thread. Return to all comments →
If someone still doesn't understand,
basically with the ORDER BY clause you can sort by multiple things, not just one. So in this example,
when the following code is executed:
ORDER BY LEN(CITY), CITY
you are first ordering by LEN(CITY) meaning that the query will order the results by the length of the city name.
So all of the city names with 3 letters, then 4, then 5, and so on....
But, this is all it does, and it will not order them any other way because you did not explicity say to do so. So now the length of the city name is sorted in ascending order, but the results are not alphabetical. This is where the ,CITY part comes in.