Merge columns in Subquery into one column on TOP

,

I have 4 subqueries I need to have all the columns under one column on TOP. I am having a brain stumble and can’t remember how. I don’t need to concatenate.

Example: Subqueries one through 4 have columns a-d. The TOP has has Columns A-d. I need all of Subqueries columns a-d to populate TOP A-D.

Merge these into the set few columns not all the blank spaces.

UNION?

Maybe?

Never done a union. There isn’t a whole lot in the Help in Epicor either. Is there anything here or can you explain how todo the Union?

Make sure all queries have the fields in the same order (names don’t matter) and they have the same type (nvarchar, int, etc.). Then, just set the query types as Union All queries (except the first one of course). If you need to use the result as a subquery, use parenthesis:

image

Try page 310 of the Epicor Ice tools users guide

1 Like

@Will79
Side thought… usually you will get this type of result if the result rows are determined unique in the join.
I can’t see your query statement, design nor the full results, so that is why I recommended a Union.
@Hally is right on where Unions are discussed in Epicor help.
But UNION is a SQL thing as well, so you can probably learn more about UNIONs, how they work and when to use them elsewhere on line.

SQL UNION overview, usage and examples (sqlshack.com)