distinct with sum
distinct with sum
От:
mbobi@mac.com
Дата:
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.
Re: distinct with sum
От:
Hélder M. Vieira <hmv@mail.telepac.pt>
Дата:
>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