Re: How to get single raws for sums in a summary table?

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: How to get single raws for sums in a summary table?
Дата
Msg-id 696053.78666.qm@web31801.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: How to get single raws for sums in a summary table?  (Ennio-Sr <nasr.laili@tin.it>)
Ответы Re: How to get single raws for sums in a summary table?  (Ennio-Sr <nasr.laili@tin.it>)
Список pgsql-novice
>
> Hi Richard (and others),
>
> I was cheering too early in my previous answer ;)
> The query is only apparently  giving a sum: in effect the value in each
> raw is just one of the values of raws having the same 'titolo'.
>
> What I had in mind was the possibility to achieve the same result I used
> to get (quite a few years back) in DBIII, when printing data and setting
> subtotals for same items. But this is history ......
>

This should would a little better.

select
        distinct on (titolo)
                     ^^^^^^
        'any' as cod_rif,
        titolo,
        (
         select A1.sum(quantity) from test_t as A1
         where A1.titolo = test_t.titolo
        ) as sum_qty,
        cmf,
        u_qq,
        mont,
        vend,
from
        test_t
group by
        titolo,
        sum_qty,
        cmf,
        u_qq,
        mont,
        vend
;


Regards,
Richard Broersma Jr.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Ennio-Sr
Дата:
Сообщение: Re: How to get single raws for sums in a summary table?
Следующее
От: Ennio-Sr
Дата:
Сообщение: Re: How to get single raws for sums in a summary table?