0 votes
1 view
in SQL by (36k points)

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

1 Answer

0 votes
by (86.2k 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 in SQL by Sudhir_1997 (36k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...