3

such as "order by col_location", if location is the same, then "order by col_time"

3 Answers 3

4
SELECT * FROM something
ORDER BY col_location, col_time DESC;
Sign up to request clarification or add additional context in comments.

Comments

1

You can string columns in an ORDER BY, separated by commas.

Comments

0

As others have said,listing the different columns in order of priority. You can also go one step further and build logic into your ORDER BY so that it becomes conditional e.g.

order by case when col_location = col_something_else then 
   col_location 
else 
   col_time 
end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.