Re: sub query - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: sub query
Date
Msg-id Pine.LNX.4.44.0309201738250.2761-100000@peter.localdomain
Whole thread Raw
In response to sub query  ("Martin Kuria" <martinkuria@hotmail.com>)
List pgsql-sql
Martin Kuria writes:

> Hi again I have this problem when I try to run this query, how can I rewrite
> it for it to work.
>
> SELECT o.item_order_num,SUM(o.item_quantity + o.item_product_id) As total,
> o.item_status
> FROM soko_product p, soko_ordered_item o
> WHERE p.product_id = o.item_product_id
> GROUP BY o.item_order_num
> ORDER BY o.item_order_num;
>
> Error: Attribute o.item_status must be GROUPED OR USE IN an aggregate
> function

Add o.item_status to the GROUP BY clause.

-- 
Peter Eisentraut   peter_e@gmx.net



pgsql-sql by date:

Previous
From: Christopher Browne
Date:
Subject: Re: auto_increment
Next
From: Tom Lane
Date:
Subject: Re: [ADMIN] Error with functions