Forum Discussion
@clarrivey - most databases have “union” and “union all”. “Union” will typically merge the results by removing any duplicates between the results sets, which is probably why they are being sorted prior to output. “Union all” generally returns all results as they are returned from each result set.
With that said, you can try “union all” and may see the results you are expecting. However, I will caution that the “header” still has a chance that it will not be returned as the first record if the database performs the separate queries concurrently.
Just from a design perspective, I’m curious why you are trying to manufacture the header record separately. Why not provide an alias name for the return values and use a CSV Formatter to generate the header row in the output?