Update Column with Percentages
695832May 7 2009 — edited May 7 2009I have a table implemeneted in a table, the column is call averages and as you can imagine i would like to fill this with percentages from the stored numbers in the table.
This is the table
Column Name Data Type Nullable Default Primary Key
PLAYER_ID NUMBER(4,0) No - 1
CONTRACT_ID NUMBER(4,0) Yes - -
FORENAME VARCHAR2(30) Yes - -
SURNAME VARCHAR2(30) Yes - -
TEAMNAME VARCHAR2(30) Yes - -
PLAYED NUMBER(10,0) Yes - -
WINS NUMBER(10,0) Yes - -
LOSES NUMBER(10,0) Yes - -
AVERAGES NUMBER(10,0) Yes - -
I tried the following statement,
update player set averages = sum(wins/played)*100;
The above statement give me the ORA-00934: group function is not allowed here error, is there any way of populating the column using the sum statement?
The table has 112 rows.
I can return the percentages using the follow statement,
select player_id, sum(wins/played)*100 as "percentage"
from player
group by player_id
having sum(wins/played)*100 > 50;
I cannot think of a way to save the return from the query.
Edited by: InvaderTak on 07-May-2009 15:19