-1

Bear with me. I'm new at this.

So, I have three queries, one after the other, the first two ending with semi-colons. It's the same data from the same tables but sliced three different ways. The 'ORDER-BY's are all the same. The results come out on three separate tabs. How do I combine the results into a single output?

1 Answers1

1

Use the UNION or UNION ALL syntax and put the order by at the end

e.g SELECT A, B FROM X UNION {ALL} SELECT A, C FROM Y UNION {ALL} SELECT D, E FROM Z order by 2;

Notes: UNION is usually a bit slower because it will remove duplicates from the results if more that one section returns the same row. UNION ALL will return all rows. The data types for columns in each section must be the same.