Howard Smith <hsmith(at)visualmining(dot)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