Re: Problems with select statement

Поиск
Список
Период
Сортировка
От Ragnar Hafstað
Тема Re: Problems with select statement
Дата
Msg-id 1108936504.10462.80.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Problems with select statement  (phil campaigne <pcampaigne@charter.net>)
Список pgsql-general
On Sun, 2005-02-20 at 16:32 -0500, phil campaigne wrote:

> hardwoodthunder=# select player_number, player_name, cum_score, (select
> player_points where aspect='A') as A ,(select player_points where
> aspect='C') as C, (select player_points where aspect='T') as T from
> (select * from player as a,teamshare as b where
> a.player_number=b.player) as c;
>
>  player_number | player_name | cum_score |  a   |  c   |  t
> ---------------+-------------+-----------+------+------+-----
>  42            | S. Randolph |         4 | 0.27 |      |
>  42            | S. Randolph |         4 |      | 0.33 |
>  42            | S. Randolph |         4 |      |      | 0.8
>  42            | S. Randolph |         2 | 0.54 |      |
>  42            | S. Randolph |         2 |      | 0.66 |
>  42            | S. Randolph |         2 |      |      | 0.8
>  40            | R. Perkins  |         4 | 0.27 |      |
>  40            | R. Perkins  |         4 |      | 0.33 |
> (8 rows)
>
> How all three (Randolph, 4) rows into one row?

how about simply:
select player_number, player_name, cum_score,sum(a),sum(c),sum(t) from
(select as above...) group by player_number, player_name, cum_score ?

gnari



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

Предыдущее
От: phil campaigne
Дата:
Сообщение: Problems with select statement
Следующее
От: Vitaly Belman
Дата:
Сообщение: Re: Returning 0 rows from a PL/PGSQL