Search Postgresql Archives

Re: average/stddev on all values returned by a select distinct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 17, 2007 at 01:51:21PM +0100, ann hedley wrote:
> What I want is the average and stddev of the set of lengths returned by 
> this query.  Something like...
> 
> select average(select distinct on (id) length(consensus) from cluster 
> order by id,length(consensus) desc);

I think this is what you're looking for:

select avg(length)
  from (
    select distinct on (id) length(consensus)
      from cluster
     order by id, length(consensus) desc
  ) s;

-- 
Michael Fuhr


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux