sql - Oracle Database Query Design -


i working on program supposed predict outcomes of 1v1 contest. have given each player own elo score , collecting sorts of data in order predict winner be.

for each fighter, want collect current average elo of people defeating current average elo of people defeating them. below sample data , explanations in order better understand data structure.

basic stats snapshot

the picture above shows basic stats view, v_fight_review simplifies fights table stats collection. fid unique fight id , identifies fight. pid player id , identifies each unique player. winner column represents winner of fight. if pid not equal winner, player did not win fight.

player table snapshot

this picture represents players table. left recognize pid each player. right see column named elo.

to rephrase question, having trouble figuring out how can produce current average elo of each player have defeated , current average elo of each player has defeated them. these average elos should change opponents win/lose fights. output should similar below:

pid | avg_elo_def | avg_elo_def_by

i 99% sure there better way here answer came with.

i created new view query:

select  w.fid, w.pid winner, l.pid loser, w.elo winner_elo, l.elo loser_elo    (select * v_fight_review pid = winner , fid = fid) w,     (select * v_fight_review pid <> winner , fid = fid) l w.fid = l.fid; 

this query gets elos of every winner , loser each fight.

i created 2 other views. 1 view average elos each opponent has defeated. other view average elos of opponents have defeated them. code below.

--gets average elo of oppenents can beat create view v_avg_elo_winning select p.pid, round(avg(vae.loser_elo), 0) elo players p, v_avg_elo vae p.pid = vae.winner group pid order pid;  --gets average of of people can beat them create view v_avg_elo_losing select p.pid, round(avg(vae.winner_elo), 0) elo players p, v_avg_elo vae p.pid = vae.loser group pid order pid; 

suggestions welcome.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -