mysql - DataBase-Finding total scores -


i've 15 levels, , each level consists of 2 rounds. i've find total score finding max score user earned in round1 , round2 , calculate it. likewise same method how many levels played. and, finally, total result calculating scores levels.

can please me find total score using mysql..!

i tried code:

    select *, (classifica_score + max2) total from(      select ifnull( max(xx1.classifica_score), 0) classifica_score, xx1.classifica_level, xx1.classifica_round, xx1.fb_id,     (select ifnull( max(tc1.classifica_score), 0) tab_classifica tc1 tc1.classifica_round = 2 , tc1.fb_id = xx1.fb_id) max2       tab_classifica xx1 xx1.classifica_round=1      group xx1.classifica_level, xx1.classifica_round, xx1.fb_id  union   select ifnull( max(xx2.classifica_score),0) classifica_score, xx2.classifica_level, xx2.classifica_round, xx2.fb_id, (select ifnull( max(tc2.classifica_score),0) tab_classifica tc2 tc2.classifica_round = 1 , tc2.fb_id = xx2.fb_id ) max1   tab_classifica xx2 xx2.classifica_round=2 group xx2.classifica_level, xx2.classifica_round, xx2.fb_id    ) tab  

my db structure follows

classifica_id----- fb_id---classifica_nome----classifica_level----classifica_round---classifica_score 


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -