pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gaetano Mendola <mendola@bigfoot.com>
To: Kaloyan Iliev Iliev <news1@faith.digsys.bg>
Subject: Re: Problems with UNION ALL and ORDER BY
Date: Mon, 02 Aug 2004 18:45:50 +0200
Message-ID: <410E6FBE.9000103@bigfoot.com> (raw)
In-Reply-To: <410E6376.1010404@faith.digsys.bg>
References: <410E6376.1010404@faith.digsys.bg>

Kaloyan Iliev Iliev wrote:
> 
> Dear friends...,
> I have the following problem:
> 
> 
> select  .....  from  ....  where  ....
> UNION ALL
> 
> select ...  from  ....  where  ....
> ORDER BY field1
> 
> But the the order by doesn't work properly. It returns the rows of the 
> first query ordered and then appends the rows of the second query 
> ordered. But this is not what i expect. I expect the result of both 
> queries to be orderd. So I try.
> 
> SELECT TEMP.*
> FROM
> (
> select ..... from  ....  where  ....
> UNION ALL
> 
> select ...  from  ....  where ....
> ) TEMP
> ORDER BY TEMP.field1
> 
> But this also doesn't work. Any ideas.p

This have to work. Could you please provide a real example ( creation table,
insertion data and query execution ).


Regards
Gaetano Mendola





view thread (7+ messages)  latest in thread

Message-ID: <410E6FBE.9000103@bigfoot.com>
Permalink:  ../410E6FBE.9000103@bigfoot.com/
Also on:    postgresql.org/message-id/410E6FBE.9000103@bigfoot.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mendola@bigfoot.com, news1@faith.digsys.bg
  Subject: Re: Problems with UNION ALL and ORDER BY
  In-Reply-To: <410E6FBE.9000103@bigfoot.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox