pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: chester c young <chestercyoung@yahoo.com>
To: Alexy Khrabrov <deliverable@gmail.com>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: columns for count histograms of values
Date: Wed, 30 Apr 2008 16:12:12 -0700 (PDT)
Message-ID: <357171.1486.qm@web54307.mail.re2.yahoo.com> (raw)
In-Reply-To: <824FF9F9-9997-4AD9-9955-3CA658E150D4@gmail.com>


--- Alexy Khrabrov <deliverable@gmail.com> wrote:

> Greetings -- I have a table of the kind
> 
> Ratings:
> id integer
> rating smallint
> 
> -- where value can take any value in the range 1 to 5.  Now I want to
>  
> have a statistical table Stats of the form
> 
> id integer
> min smallint
> max smallint
> avg real
> r1 integer
> r2 integer
> r3 integer
> r4 integer
> r5 integer
> 
> -- how can I create it in one pass over Ratings? 

select id, min(rating), max(rating), avg(rating),
  sum( case rating = 1 then 1 else 0 end ),
  ...



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



view thread (2+ messages)

Message-ID: <357171.1486.qm@web54307.mail.re2.yahoo.com>
Permalink:  ../357171.1486.qm@web54307.mail.re2.yahoo.com/
Also on:    postgresql.org/message-id/357171.1486.qm@web54307.mail.re2.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chestercyoung@yahoo.com, deliverable@gmail.com
  Subject: Re: columns for count histograms of values
  In-Reply-To: <357171.1486.qm@web54307.mail.re2.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox