Re: [GENERAL] trouble with sum

From: Marcin Grondecki <ojciec(at)mtl(dot)pl>
To: pete collins <pcollins(at)ocsny(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] trouble with sum
Date: 1999-03-20 04:13:02
Message-ID: 3.0.6.32.19990319201302.00831190@mtl.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Should work :)
In group by you should group by ALL non-aggregate fields,
in this example - s.product_id too.
But in your original question you wrote "where s.product_id=p.product_id",
so one of these fields became redundant.

At 14:16 99-03-19 -0500, pete collins wrote:
>=> select sum(P.price), P.product_id, S.sid, S.product_id from products P,
>shoppers S
>-> where S.sid='0319199910043810.3.0.12'
>-> group by P.product_id, S.sid;
>ERROR: parser: illegal use of aggregates or non-group column in target list
>
>
>
>no luck
>i wont let me combine sum(P.price) with the other selects
>
>this should work right?
>

Marcin Grondecki
ojciec(at)mtl(dot)pl
+48(604)468725
***** I'm not a complete idiot, some parts are missing...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ronald L. Chichester 1999-03-20 04:17:25 Web Tools
Previous Message Marcin Grondecki 1999-03-20 04:05:48 Re: [GENERAL] database-level locking