distinct with sum

From: mbobi(at)mac(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: distinct with sum
Date: 2006-07-09 08:33:44
Message-ID: 5644020.1152434024188.JavaMail.mbobi@mac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Hélder M. Vieira 2006-07-09 12:41:52 Re: distinct with sum
Previous Message Luca Giandoso 2006-07-09 07:52:35 information_schema for all users