From the course: Oracle Database 19c: Advanced SQL

Unlock the full course today

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

Using ORDER BY with set operators

Using ORDER BY with set operators - Oracle Database Tutorial

From the course: Oracle Database 19c: Advanced SQL

Start my 1-month free trial

Using ORDER BY with set operators

- [Instructor] Now we've finally made it to the ORDER BY clause and how it works with Set Operators. The diagram shows the four Set Operators you can use in Oracle Database. Union, Union All, Intersect, and Minus. We're on the ORDER BY clause for all of them. The syntax for said operators is straightforward. Multiple select statements joined by any of the Set Operators. The diagram shows a subset of the select clause. Using a Set Operator is as simple as joining two sub queries, which is two select statements. The select statement shown is a sample with two sub queries. They can be joined by any Set Operator and sorted with ORDER BY. But do you always need to order the results with a Set Operator? Yes, under certain circumstances. If you want to return results in a certain order put an ORDER BY at the end. Of all the Set Operators, the Union, Intersect and Minus operators will automatically sort the results. Unions All does not. Notice that sorting is required anyway to remove…

Contents