우선 학생의 점수가 몇등급인지 알 수 있도록 두 테이블 students, grades를 join해야한다.
또한, 8등급 미만인 학생의 이름은 NULL 처리를 해야하므로 select 절에서 if 문을 사용하였는데, 8등급의 최소 점수가 70점이므로 다음과 같이 작성하였다.
select if(t1.marks<70, 'NULL', t1.name), t2.grade, t1.marks
from students as t1
join grades as t2
on t1.marks between t2.min_mark and t2.max_mark
order by t2.grade desc, t1.name