pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tiberiu Craciun <tiberiu@akela.ro>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] calculating percentages
Date: Mon, 12 Jul 1999 17:53:36 +0300
Message-ID: <00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro> (raw)

There is an example :

create table values ( value float ) ;
create function sum_val() returns float as '
    select sum(value) as return from values;
' language 'sql';
..........
select (value/sum_val())*100 as percent from values;

if value is integer than

create table values ( value int2 ) ;
create function sum_val() returns int2 as '
    select sum(value) as return from values;
' language 'sql';
..........
select (value::float/sum_val()::float)*100 as percent from values;


-----Original Message-----
From: Thomas Good <tomg@admin.nrnet.org>
To: PostgreSQL::SQL List <pgsql-sql@postgreSQL.org>
Date: lundi 12 juillet 1999 22:31
Subject: [SQL] calculating percentages


>Hi.
>
>I am trying to do outcome studies on pt before and after treatment
>recidivism rates...and having some trouble calculating percentages.
>
>How does one do this:   SELECT (current_value/target) * 100;
>in postgres?  
>
>Cheers - and thanks,
>Tom
>
>------- North Richmond Community Mental Health Center -------
>
>Thomas Good                                   MIS Coordinator
>Vital Signs:                  tomg@ { admin | q8 } .nrnet.org
>                                          Phone: 718-354-5528  
>                                          Fax:   718-354-5056  
>                              
>/* Member: Computer Professionals For Social Responsibility */ 
>
>
>

view thread (13+ messages)  latest in thread

Message-ID: <00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro>
Permalink:  ../00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro/
Also on:    postgresql.org/message-id/00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro

 · 

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: tiberiu@akela.ro
  Subject: Re: [SQL] calculating percentages
  In-Reply-To: <00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro>

* 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