Skip to content
Advertisement

sql how to sort by a union’s subquery without adding a column?

So I mostly have the query I need, but I noticed that I still get duplicates from the first select and the second select. I thought that using UNION instead of UNION ALL would remove duplicates, but because they have a different sequence number they are not removed. How can I order my results by the select statement without adding an unnecessary seq column?

Advertisement

Answer

You can do this using order by:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement