Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone explain how to use order by in union query in SQL?

1 Answer

0 votes
by (119k points)

Here is the syntax to use ORDER BY clause along with UNION operator in a query:

SELECT column1, column2,……column

FROM table_name

WHERE condition

UNION

SELECT column1, column2,……column

FROM table_name

WHERE condition

ORDER BY column_name;

In the above SQL query, the ORDER BY clause will be applied to the complete result set.

If you want to learn SQL from Industry experts, I suggest this SQL Certification course by Intellipaat that provides Instructor-led training, hands-on experience, and certification.

Related questions

0 votes
1 answer
asked Jul 12, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Apr 28, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked May 5, 2020 in SQL by Sudhir_1997 (55.6k points)

Browse Categories

...