php - How to add scores like 'A','B','C' with mySQL -


hello want ask something

how add scores b c d mysql query

select dcm_peserta.nm1, count(siswa.nis) jml, round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) percent          /* add select scoring here */ dcm_peserta, siswa siswa.id_kelas = dcm_peserta.id_kelas , dcm_peserta.id_kelas = '65' group dcm_peserta.nis 

like if percent = 0 score a, if percent = 1 until 20 score b

any idea?

if have in query, use case:

note cases processed top down in same way if...elseif structure be, not need explicit range (i.e. have done >80 after =100, 'f' selected if =100 not pass. is, >80 , <> 100.)

select ...     case when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) = 100 'g'          when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) > 80 'f'          when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) > 60 'e'          when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) > 40 'd'          when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) > 20 'c'          when round(dcm_peserta.nm1 / count(dcm_peserta.nis) * 100) > 0 'b'          else 'a'     end score ... 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -