Re: columns for count histograms of values

From: "Mag Gam" <magawake(at)gmail(dot)com>
To: "Alexy Khrabrov" <deliverable(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: columns for count histograms of values
Date: 2008-05-01 01:32:51
Message-ID: 1cbd6f830804301832j48a3dd1ehfb4d1d0a2510d3af@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Just curious, how are you planning to display the histogram?
Are you allowed to use application code (C/C++/Perl, etc..) to generate the
histogram? Personally, SQL is great for showing the data but not good for
making graphs with data you can show.

On Wed, Apr 30, 2008 at 5:01 PM, Alexy Khrabrov <deliverable(at)gmail(dot)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? I can use min(), max(),
> avg() for
> insert into stats values (id,select min(rating), max(rating), avg(rating),
> ...) from ratings
>
> -- but what to do for r1,..,r5, short of subselects (select count(rating)
> from ratings where stats.id=ratings.id) for each, which is an overkill?
>
> Also, if a table Stats already exists with some more columns, and we need
> to do an update, not insert, for the above, how would that work --
>
> update stats set min=min(ratings), ... from ratings where stats.id=
> ratings.id -- how do we do the histogram in this case, where the id is
> fixed explicitly?
>
> Cheers,
> Alexy
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alexy Khrabrov 2008-05-01 08:35:46 Re: columns for count histograms of values
Previous Message chester c young 2008-04-30 23:12:12 Re: columns for count histograms of values