From the course: Oracle Database 19c: Basic SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

ORDER BY clauses

ORDER BY clauses

From the course: Oracle Database 19c: Basic SQL

Start my 1-month free trial

ORDER BY clauses

- In this video I'll talk about the order by clause. After I show you the general syntax, you'll know where to put it and what can be in it, and where you can't put it. I'll also show you some edge cases where it could be somewhere in the middle, but it usually doesn't make sense. What does the order by syntax look like? Here's the syntax diagram. It always goes at the end of the select statement, and you can order each column or expression in either ascending or descending order. The default is ascending. If any of your columns or expressions have a null value, by default they go at the end, null is last, or you can override the behavior by specifying null is first, instead. You can use the siblings clause with hierarchical queries, which won't be covered in this course. Here's a very basic example of sorting the departments table by two of the columns, Manager ID, and Department Name. I'm sorting first by Manager ID, then Department Name within manager, and many of the departments…

Contents