Subject | Ordering of union results |
---|---|
Author | Rick Debay |
Post date | 2005-09-30T21:19:32Z |
I have three queries that I aggregate with a union. I'd like the
results from the first query placed before the second, and the second
before the third. I accomplished this by adding a number to the end of
the results for each query, and ordering by that column:
Select x,y,z,1
From query1
Union
Select x,y,z,2
From query2
Union
Select x,y,z,3
From query3
Order by 4
This worked, but duplicates are no longer surpressed. If I remove the
order by clause, will the results be ordered by their order around the
union predicates, or is it undetermined.?
Thanks, Rick DeBay
results from the first query placed before the second, and the second
before the third. I accomplished this by adding a number to the end of
the results for each query, and ordering by that column:
Select x,y,z,1
From query1
Union
Select x,y,z,2
From query2
Union
Select x,y,z,3
From query3
Order by 4
This worked, but duplicates are no longer surpressed. If I remove the
order by clause, will the results be ordered by their order around the
union predicates, or is it undetermined.?
Thanks, Rick DeBay