Re: UNION and LIMIT issue - Mailing list pgsql-sql

From Tom Lane
Subject Re: UNION and LIMIT issue
Date
Msg-id 10865.1184884079@sss.pgh.pa.us
Whole thread Raw
In response to UNION and LIMIT issue  (Howard Smith <hsmith@visualmining.com>)
List pgsql-sql
Howard Smith <hsmith@visualmining.com> writes:
>       SELECT name,quantity FROM fruit limit 3
>       UNION
>                select name,CAST(SUM(quantity) as integer) from (
>               select Cast('Other' as varchar) as name,quantity from fruit
>               limit ALL offset 3
>        ) w   group by name

You need parentheses:
(SELECT ... limit 3) UNION ...

ISTM that a LIMIT without an ORDER BY is a pretty bad idea, btw.
        regards, tom lane


pgsql-sql by date:

Previous
From: Howard Smith
Date:
Subject: UNION and LIMIT issue
Next
From: ljb
Date:
Subject: Re: UNION and LIMIT issue