| От | Gregory Stark |
|---|---|
| Тема | Re: Generating subtotal reports direct from SQL |
| Дата | |
| Msg-id | 87bqb7byib.fsf@oxford.xeocode.com обсуждение исходный текст |
| Ответ на | Generating subtotal reports direct from SQL (Owen Hartnett <owen@clipboardinc.com>) |
| Ответы |
Re: Generating subtotal reports direct from SQL
|
| Список | pgsql-general |
"Owen Hartnett" <owen@clipboardinc.com> writes: > Such that the final table has additional subtotal rows with the aggregate sum > of the amounts. I'm thinking I can generate two tables and merge them, but is > there an easier way using a fancy Select statement? Unfortunately the fancy SQL feature you're looking for is ROLLUP which Postgres doesn't support. I think you would have to do ( select id, code, amount from foo where code < 10 union all select null, code, sum(amount) from foo where code < 10 group by code ) order by code, id -- Gregory Stark EnterpriseDB http://www.enterprisedb.com
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера