Skip site navigation (1) Skip section navigation (2)

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 23:41:23
Message-ID: 20061122234123.GA8930@deby.ei.hnet (view raw or flat)
Thread:
Lists: pgsql-novice
* Richard Broersma Jr <rabroersma(at)yahoo(dot)com> [221106, 15:30]:
> 
> > -----------------------------------
> > 
> > PS: I didn't go through all pg-documentation so my guess might be a bit
> > of hazard: shouldn't the 'distinct on (some_field)'  do all the job on its own 
> > with no need for the second (sub)select? Otherwise there seems to be no
> > difference between 'select distinct on (fx) f1, f2, .,fx,. ,fn' and
> > 'select distinct f1, f2, .,fx,. fn'.
> > 
> 
> I think that distinct on works like a where clause. So if filter out records rather than grouping
> them. So you end up with a sum of 1 record.
> 
> Regards,
> 
> Richard Broersma jr.

Thank you, Richard, for this further element of knowledge!

In the meantime I've tested the real table and your query works like a
charm: now, finally, my nice (coloured) summary table tells the 'truth' :-)))

Cheers,
	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

pgsql-novice by date

Next:From: developer_studentDate: 2006-11-23 22:13:59
Subject: How to execute a system command inside a SQL statement
Previous:From: Richard Broersma JrDate: 2006-11-22 23:30:25
Subject: Re: How to get single raws for sums in a summary table?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group