| From: | Hélder M(dot) Vieira <hmv(at)mail(dot)telepac(dot)pt> |
|---|---|
| To: | <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: distinct with sum |
| Date: | 2006-07-09 12:41:52 |
| Message-ID: | 000f01c6a355$0dbf8240$6200a8c0@hmv02 |
| Views: | Whole Thread | Raw Message | 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
select id_prod, id_unit, sum(quantity) as result
from products
where determinant = false
group by id_prod, id_unit
Hélder M. Vieira
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Fuhr | 2006-07-09 18:10:10 | Re: information_schema for all users |
| Previous Message | mbobi | 2006-07-09 08:33:44 | distinct with sum |