php - Skipping Ranking in Rows which do not meet required value from Mysql sorted ranking with ties? -


i have googled , searched through stack site , not find atleast give me ideas on how achieve this. calculated ranking sum of totalscore student , determined ties sql variable. each student has 5 subjects , can have tests more once in week. want skip student score less 35% of totalscored in each subject ranking. example, student gets 40 out of 100 in english, 59 out of 100 in mil, 110 out of 130 in science, 98 out of 120 in mathematics, 33 out of 100 in ss. if fullmark each subject 100, can calculate using following query:

  select regd,         english, mil,           mathematics, ss,         science,          score, fmscore, perc, rank                   (         select t.*, if(@p = score, @n, @n := @n + 1) rank, @p := score                  (         select regd,              sum(if(subject = 'english'    , mark_score, 0)) english,             sum(if(subject = 'mil'       , mark_score, 0)) mil,             sum(if(subject = 'mathematics', mark_score, 0)) mathematics,              sum(if(subject = 'ss'         , mark_score, 0)) ss,             sum(if(subject = 'science'    , mark_score, 0)) science,             sum(full_mark) fmscore,             sum(mark_score) score,              sum(mark_score) / sum(full_mark) * 100 perc          exam e1, (select @n := 0, @p := 0) n          not exists (select null exam e2 e1.regd = e2.regd         , e2.mark_score/e2.full_mark<0.35)         group regd          order score desc         ) t         ) r; 

because fullmark each subject different , not 100, code not correctly skip ranks students less 35% of full mark in 1 or more subjects. if not achieved using mysql alone, there possibilities using php array? in exam table id primary key, , regd indexed. project , have been stucked here month now. please me.

you need first group data regd subject wise. can able calculate percentage against each subject , remove less defined limit. once achive this, can carry output , use show , create rank. can use below query.

 select regd, sum(if(subject = 'english'    , mark_score, 0)) english,             sum(if(subject = 'mil'       , mark_score, 0)) mil,             sum(if(subject = 'mathematics', mark_score, 0)) mathematics,              sum(if(subject = 'ss'         , mark_score, 0)) ss,             sum(if(subject = 'science'    , mark_score, 0)) science,             mark_score, perc             (         select regd, subject,(sum(mark_score) / sum(full_mark) * 100) perc , (sum(mark_score)) mark_score         exam e1         group regd, subject         having perc > 35          ) t           order mark_score; 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -