From: mbobi@mac.com
To: pgsql-sql@postgresql.org
Subject: distinct with sum
Date: Sun, 09 Jul 2006 10:33:44 +0200
Message-ID: <5644020.1152434024188.JavaMail.mbobi@mac.com> (raw)
I need to list products from the table of ordered products with ordered quantities. Each product should be there only once but quantity should be a sum from all the same products from the table.
I prepared some query but in quantity column I can see only amount from one record. I need to have sum there.
The query:
select distinct on (id_prod) id_prod, id_unit, sum(quantity) as result from products where determinant = false group by id_prod, id_unit
Thanks in advance for your help.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mbobi@mac.com
Subject: Re: distinct with sum
In-Reply-To: <5644020.1152434024188.JavaMail.mbobi@mac.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox