Re: Intersect and order by
| От | Michael Fork |
|---|---|
| Тема | Re: Intersect and order by |
| Дата | |
| Msg-id | Pine.BSI.4.21.0102281349080.9658-100000@glass.toledolink.com обсуждение исходный текст |
| Ответ на | Intersect and order by (Michaël Fiey <m.fiey@futuresoundtech.com>) |
| Список | 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] Micha�l 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
>
>
>
В списке pgsql-general по дате отправления: