Re: How to obtain algebraic sum of equal lines - Mailing list pgsql-novice

From Ennio-Sr
Subject Re: How to obtain algebraic sum of equal lines
Date
Msg-id 20060425215338.GA13828@deby.ei.hnet
Whole thread Raw
In response to Re: How to obtain algebraic sum of equal lines  (Oisin Glynn <me@oisinglynn.com>)
List pgsql-novice
* Oisin Glynn <me@oisinglynn.com> [250406, 17:24]:
> Ennio-Sr wrote:
> >Hi Oisin and Frank,
> >
> >* Frank Bax <fbax@sympatico.ca> [250406, 16:41]:
> >
> >>At 04:12 PM 4/25/06, Ennio-Sr wrote:
> >>
> >>
> >>>Hi all,
> >>>Is it possible, given the following table:
> >>> ...
> >
> >The point is that command would return two cols only, whereas I would
> >like to have all the cols, like:
> >
> > 26      | aaa    |     1500 | 6.11098 |  6.176 |  6.1110 | t    |  1500
> > 28      | bbb    |     2000 |   3.862 |    4.6 |  4.1957 | f    |  3200
> >
> >i.e. aaa=(-1000+2500=1500), bbb=(2700+500-700-500)=2000
> >which, I fear, is not possible ;-(
> >
> >
> select *,(select sum(quantity) from test_t t2 where t2.titolo=t1.titolo)
> as sum  from test_t t1;
>
> would do it though who knows how inefficient this is?
>

Well, it's better than nothing, anyway. At list I'll get the balance
quantity for each equal titolo :-)
Thank you Oisin!
Regards,
    Ennio.

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!"  (diceva Henry Miller) ]    (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that.              )=(
 Do something you aren't good at!" (as Henry Miller used to say) ]

pgsql-novice by date:

Previous
From: Ennio-Sr
Date:
Subject: Re: How to obtain algebraic sum of equal lines
Next
From: Mark Campbell
Date:
Subject: Perl and psql variables