Re: [SQL] calculating percentages

Поиск
Список
Период
Сортировка
От Tiberiu Craciun
Тема Re: [SQL] calculating percentages
Дата
Msg-id 00e901becc76$521ea5a0$0201a8c0@tibi.akela.ro
обсуждение исходный текст
Список pgsql-sql
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 */
>
>
>

В списке pgsql-sql по дате отправления:

Предыдущее
От: Thomas Good
Дата:
Сообщение: calculating percentages
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Stupid question about default time value