Search Postgresql Archives

Re: A GROUP BY question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 13 Aug 2019, at 15:19, David G. Johnston <david.g.johnston@xxxxxxxxx> wrote:
> 
> On Tuesday, August 13, 2019, Alban Hertroys <haramrae@xxxxxxxxx> wrote:
> 
> > On 13 Aug 2019, at 13:10, stan <stanb@xxxxxxxxx> 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 meaningful way.
> 
> 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 on the 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 different level 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 seem a good idea in the context. Possible?, sure, desirable?, I would say not.

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










[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux