Re: A GROUP BY question

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: A GROUP BY question
Дата
Msg-id 9A246E87-E81A-46FB-A69D-021698A9B731@gmail.com
обсуждение исходный текст
Ответ на Re: A GROUP BY question  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
> On 13 Aug 2019, at 15:19, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Tuesday, August 13, 2019, Alban Hertroys <haramrae@gmail.com> wrote:
>
> > On 13 Aug 2019, at 13:10, stan <stanb@panix.com> wrote:
> >
> > select
> >       project.proj_no ,
>
> Removed columns that get in the way of your desired result. You can’t have both details and the sum over them in a
meaningfulway. 
>
> Sure you can, at least generally, with Window Functions/Expressions (i.e., OVER)

That’s why I added “in a meaningful way” ;)

Repeating the same SUM-result on every line in a group is not what I’d call a meaningful result; the SUM has no bearing
onthe detailed line and leads to the kind of mistakes I already mentioned. 
(For the record; I do this kind of grouping in a hierarchical database regularly, but there the grouped SUM is at a
differentlevel in the hierarchy and I consider it thus sufficiently separated from the detail rows.) 

Besides, I figured the OP was already struggling with the query syntax, adding window functions into the mix didn’t
seema good idea in the context. Possible?, sure, desirable?, I would say not. 

Alban Hertroys
--
There is always an exception to always.







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

Предыдущее
От: Souvik Bhattacherjee
Дата:
Сообщение: Re: Bulk Inserts
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Bulk Inserts