Re: UNION and ORDER BY

From: Dmitry Tkach <dmitry(at)openratings(dot)com>
To: Cool Screen <cool_screen_name90001(at)yahoo(dot)com>
Subject: Re: UNION and ORDER BY
Date: 2002-11-07 21:01:56
Message-ID: 3DCAD4C4.1060106@openratings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I *think* if you use unionall, it should do what you want here...

I hope, it helps.

Dima

Cool Screen wrote:
> With:
>
> (select *
> from table1
> where col1=1
> order by name)
> union
> (select *
> from table1
> where col1=2
> order by random())
>
> UNION apparently reorders all the rows of the result
> in their natural order (sequence in which they where
> inserted). Is there a way to have the first part of
> the results ordered by name, and the second part by random()?
>
> __________________________________________________
> Do you Yahoo!?
> U2 on LAUNCH - Exclusive greatest hits videos
> http://launch.yahoo.com/u2
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-11-07 21:03:04 request new feature: auto recompile of function when oid not found
Previous Message Tom Lane 2002-11-07 20:57:45 Re: UNION and ORDER BY