Search Postgresql Archives

Problem with select statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes Gnari it works now!
all I had to do in addition to your advice was  alias the sub select:

hardwoodthunder=# select player_number,player_name,cum_score,sum(a),sum(c),sum(t) from ( 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) as B group by player_number, player_name, cum_score;
player_number | player_name | cum_score | sum | sum | sum
---------------+-------------+-----------+------+------+-----
40 | R. Perkins | 4 | 0.27 | 0.33 |
42 | S. Randolph | 2 | 0.54 | 0.66 | 0.8
42 | S. Randolph | 4 | 0.27 | 0.33 | 0.8
(3 rows)


Now what about the total? How do I add another column that is the sum of a,c,t?

I tried sum(sum(a),sum(c),sum(t)) but it doesn't work.
Thanks,
Phil





---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux