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

From: Ennio-Sr <nasr(dot)laili(at)tin(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to get single raws for sums in a summary table?
Date: 2006-11-22 17:31:30
Message-ID: 20061122173130.GA5217@deby.ei.hnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Richard,

* Richard Broersma Jr <rabroersma(at)yahoo(dot)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) ]

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Ennio-Sr 2006-11-22 19:22:15 Re: How to get single raws for sums in a summary table?
Previous Message Richard Broersma Jr 2006-11-22 14:53:32 Re: How to get single raws for sums in a summary table?