Skip site navigation (1) Skip section navigation (2)

Re: Intersect and order by

From: Michael Fork <mfork(at)toledolink(dot)com>
To: Michaël Fiey <m(dot)fiey(at)futuresoundtech(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Intersect and order by
Date: 2001-02-28 18:55:47
Message-ID: Pine.BSI.4.21.0102281349080.9658-100000@glass.toledolink.com (view raw or flat)
Thread:
Lists: pgsql-general
Either of these should fix your problem:

SELECT col1 as my_col
FROM table
WHERE <conditions 1>
INTERSECT
SELECT col1 as my_col
FROM table
WHERE <conditions 2>
ORDER BY my_col

- OR -

SELECT col1
FROM table
WHERE <conditions 1>
INTERSECT
SELECT col1
FROM table   
WHERE <conditions 2>
ORDER BY 1
        ^^^
        Ordinal value of field to order by

To use UNION/INTERSECT/EXCEPT with ORDER BY, you must order by the ordinal
value of the field or by the aliased field name.

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Wed, 28 Feb 2001, [iso-8859-1] Michal Fiey wrote:

> Hi,
> 
> I don't understand what's happening with my command
> I read postgresql docs, it should work...What's the problem ?
> The command is :
> 
> select col1
> from table
> where <conditions 1>
> intersect
> select col1
> from table
> where <conditions 2>
> order by col1
> 
> It does not work and return "get_sortgroupclause_expr: ORDER/GROUP BY
> expression not found in targetlist"
> 
> I use pgsql 7.03 ont redhat 7.0.
> 
> Any help would be appreciated
> 
> michael
> 
> 
> 


In response to

pgsql-general by date

Next:From: will trillichDate: 2001-02-28 19:36:51
Subject: Re: PostgreSQL packages for Debian potato
Previous:From: Tom LaneDate: 2001-02-28 18:44:39
Subject: Re: Slowdown problem when writing 1.7million records

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group