If you want to sort the results returned from the query using the UNION operator, you need to use ORDER BY clause in the last SQL SELECT statement. You can put each SELECT statement in the parentheses and use the ORDER BY clause as the last statement.
Let’s take a look at the following example: