Mysql Ranking Query on 2 columns -


table

  id       user_id     rank_solo     lp    1             1            15     45    2             2             7     79    3             3             17    15 

how can sort out ranking query sorts on rank_solo ( ranges 0 28) , if rank_solo = rank_solo , uses lp ( 0-100) further determine ranking? (if lp = lp, add ranking no tie rankings)

the query should give me ranking random user_id. how performance wise on 5m+ rows?

so

user_id 1 have ranking 2

user_id 2 have ranking 3

user_id 3 have ranking 1

you can ranking using variablesl

select t.*, (@rn := @rn + 1) ranking t cross join        (select @rn := 0) params order rank_solo desc, lp; 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -