| От | Hélder M. Vieira |
|---|---|
| Тема | Re: distinct with sum |
| Дата | |
| Msg-id | 000f01c6a355$0dbf8240$6200a8c0@hmv02 обсуждение исходный текст |
| Ответ на | distinct with sum (mbobi@mac.com) |
| Список | 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
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера