mysql equation inside where clause and between -


i need compute math equation , check if within range stored in table.something below table:

+--------------+-------+--------+-------+--------+ | no    | total | out of  |  grad   | point      | +--------------+-------+--------+-------+--------+ | 1000  | 833   |  1100   |       |     12     | +--------------+-------+--------+-------+--------+ 

av tried achieve following

query

select no,sum(score) total,(100*count(scores.code)) "out of",        grad, point  scores,gradings  (no=1000) , (exam=1)  , ((sum(score)/(100*count(exams_scores.subject_code))*100)    between gradings.range_begin , gradings.range_end) ; 

gradings table

+---------------------------------------------------+ | id   | range_begin  | range_end |  grad  | point  | +---------------------------------------------------+ | 1    |  70          |  80       |      | 12     | +---------------------------------------------------+ | 2    |   60         |  70       | b      | 11     | +---------------------------------------------------+ 

scores table

+---------------------------------------+ | no      |  exam   |  code    | score  | +---------------------------------------+ |1000     |   1     | 121      | 70     | +---------------------------------------+ |1000     |    1    | 231      | 80     | +---------------------------------------+ |1001     |     1   | 121      |  56    | +---------------------------------------+ |1001     |    1    |  231     |  85    | +---------------------------------------+     

i getting

error message

mysql error 1111 (hy000): invalid use of group function 

i think error comes equation between clause dont know how solve it..

can ?

first, add exam scores per student no totals:

select `no`, sum(score) total, 100*count(`code`) outof scores exam=1 group `no` 

then, join result of query gradings:

select s.`no`, s.total, s.outof, g.grad, g.point (     select `no`, sum(score) total, 100*count(`code`) outof     scores     exam=1     group `no` ) s join gradings g on s.total/s.outof*100 between g.range_begin , g.range_end s.`no`=1000; 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -