> -----------------------------------
>
> 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.