|
|
I've got A = FOREACH ... B = FOREACH ... C = FOREACH ... ...
X = UNION A, B, C,...
Each of the A, B, C data is a single tuple. I want X ordered by the order specified in the UNION. The data in A, B, C, ... is not necessarily in explicit sort order so ORDER X by field does not work. I've tried breaking the union into only unioning two pieces then that union plus another piece, etc. That does not work either.
Anyone have any ideas how to do this elein [EMAIL PROTECTED]
Thejas M Nair 2010-07-29, 01:05
As you observed, union does not guarantee the ordering . You will need to project an additional column indicating the order you want, so that you can do an order-by on it.
-Thejas
On 7/28/10 2:45 PM, "elein" <[EMAIL PROTECTED]> wrote:
I've got A = FOREACH ... B = FOREACH ... C = FOREACH ... ...
X = UNION A, B, C,...
Each of the A, B, C data is a single tuple. I want X ordered by the order specified in the UNION. The data in A, B, C, ... is not necessarily in explicit sort order so ORDER X by field does not work. I've tried breaking the union into only unioning two pieces then that union plus another piece, etc. That does not work either.
Anyone have any ideas how to do this elein [EMAIL PROTECTED]
Yes, Thank you. I was trying to avoid adding a sort column. On Jul 28, 2010, at 6:05 PM, Thejas M Nair wrote:
> As you observed, union does not guarantee the ordering . You will need to project an additional column indicating the order you want, so that you can do an order-by on it. > > -Thejas > > > > On 7/28/10 2:45 PM, "elein" <[EMAIL PROTECTED]> wrote: > > > > I've got > A = FOREACH ... > B = FOREACH ... > C = FOREACH ... > ... > > X = UNION A, B, C,... > > Each of the A, B, C data is a single tuple. I want X ordered > by the order specified in the UNION. The data in A, B, C, ... is not > necessarily in explicit sort order so ORDER X by field does not work. I've tried breaking > the union into only unioning two pieces then that union plus another piece, etc. > That does not work either. > > Anyone have any ideas how to do this > > > elein > [EMAIL PROTECTED] > > > > > >
elein [EMAIL PROTECTED]
|
|