Re: percentages of a column

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: percentages of a column
Дата
Msg-id 87ved6krgw.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на percentages of a column  (Andreas <maps.on@gmx.net>)
Список pgsql-sql
"Andreas" <maps.on@gmx.net> writes:

> Example:
>
> Fruit          Count       %
> --------------------------
> Bananas       5          10%
> Apples       15          30%
> Oranges     30          60%

select fruit_name, count(*),       round(count(*)::numeric / (select count(*) from basket) * 100, 0)::text||'%' as "%"
frombasket group by fruit_nameorder by "%";
 
fruit_name | count |  %  
------------+-------+-----Bananas    |     5 | 10%Apples     |    15 | 30%Oranges    |    30 | 60%
(3 rows)

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



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

Предыдущее
От: Andreas
Дата:
Сообщение: percentages of a column
Следующее
От: dBHS Jakarta
Дата:
Сообщение: Query Problem from FoxPro???