Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: columns for...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 3447 of 3799
Post > Topic >>

Re: columns for count histograms of values

by magawake@[EMAIL PROTECTED] ("Mag Gam") Apr 30, 2008 at 09:32 PM

------=_Part_3865_26389142.1209605571100
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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@[EMAIL PROTECTED]
>
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@[EMAIL PROTECTED]
)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

------=_Part_3865_26389142.1209605571100
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Just curious, how are you planning to display the histogram? <br>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.<br>
<br><br><br><div class="gmail_quote">On Wed, Apr 30, 2008 at 5:01 PM,
Alexy Khrabrov &lt;<a
href="mailto:deliverable@[EMAIL PROTECTED]
">deliverable@[EMAIL PROTECTED]
>&gt;
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Greetings -- I have a table of the kind<br>
<br>
Ratings:<br>
id integer<br>
rating smallint<br>
<br>
-- where value can take any value in the range 1 to 5. &nbsp;Now I want to
have a statistical table Stats of the form<br>
<br>
id integer<br>
min smallint<br>
max smallint<br>
avg real<br>
r1 integer<br>
r2 integer<br>
r3 integer<br>
r4 integer<br>
r5 integer<br>
<br>
-- how can I create it in one pass over Ratings? &nbsp;I can use min(),
max(), avg() for<br>
insert into stats values (id,select min(rating), max(rating), avg(rating),
...) from ratings<br>
<br>
-- but what to do for r1,..,r5, short of subselects (select count(rating)
from ratings where stats.id=<a href="http://ratings.id"
target="_blank">ratings.id</a>) for each, which is an overkill?<br>
<br>
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 --<br>
<br>
update stats set min=min(ratings), ... from ratings where stats.id=<a
href="http://ratings.id"
target="_blank">ratings.id</a> -- how do we do
the histogram in this case, where the id is fixed explicitly?<br>
<br>
Cheers,<br>
Alexy<br><font color="#888888">
<br>
-- <br>
Sent via pgsql-sql mailing list (<a href="mailto:pgsql-sql@[EMAIL PROTECTED]
"
target="_blank">pgsql-sql@[EMAIL PROTECTED]
>)<br>
To make changes to your subscription:<br>
<a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br>
</font></blockquote></div><br>

------=_Part_3865_26389142.1209605571100--
 




 4 Posts in Topic:
columns for count histograms of values
deliverable@[EMAIL PROTEC  2008-04-30 14:01:13 
Re: columns for count histograms of values
magawake@[EMAIL PROTECTED  2008-04-30 21:32:51 
Re: columns for count histograms of values
chestercyoung@[EMAIL PROT  2008-04-30 16:12:12 
Re: columns for count histograms of values
deliverable@[EMAIL PROTEC  2008-05-01 01:35:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 21:56:38 CST 2008.