Re: How to get single raws for sums in a summary table? - Mailing list pgsql-novice

From Ennio-Sr
Subject Re: How to get single raws for sums in a summary table?
Date
Msg-id 20061122173130.GA5217@deby.ei.hnet
Whole thread Raw
In response to Re: How to get single raws for sums in a summary table?  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-novice
Hi Richard,

* Richard Broersma Jr <rabroersma@yahoo.com> [221106, 06:53]:
> Oops I tested this and didn't get what you wanted. try this instead.
>
> >
> > This is untested. Also I am not sure that this is what you want, but I do not know how you
> > arrive
> > at the values in your summary table.
> >
> > select
> >         distinct on (titolo)
>                        ^^^^^^
> >         'any' as cod_rif,
> >         titolo,
> >         sum(quantity),
> >         cmf,
> >         u_qq,
> >         mont,
> >         vend,
> > from
> >         test_t
> > group by
> >         titolo,
> >         cmf,
> >         u_qq,
> >         mont,
> >         vend
> > ;
>
> Regards,
> Richard Broersma Jr.

this is exactly what I was looking for :-))) Thank you very much indeed!
I'd been trying various combinations without getting the right one ...

Now a few words  for Duncan, Peter and Andreas:

I've a table recording  purchases and sales of different items (could be
stocks, shares, car-parts, or whatever you want). Foor each item there
is a negotiation date, an initial price, a quantity, a  current price and so on.
What I was looking for was a  summary table showing the effective
quantity of the item I'm holding to-date, besides a few other data, and
Richard's solution does give that.
I know that the other data might be inaccurate: to get their
correct value I should devise a different general design for my database
(which I already have in OOo-Calc), may be a table for each item, and a
way to connect the various tables according to the desired target. But
this is only a sort of 'first aid' table ...

I hope to have clarified you doubts.

Thanks  again to all of you for your help.
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: Richard Broersma Jr
Date:
Subject: Re: How to get single raws for sums in a summary table?
Next
From: Ennio-Sr
Date:
Subject: Re: How to get single raws for sums in a summary table?