[HackerRank] The Report

데이터 분석/[Python]백준.프로그래머스

[HackerRank] The Report

INCHELIN 2021. 11. 5. 15:05
728x90

https://www.hackerrank.com/challenges/the-report/problem

 

The Report | HackerRank

Write a query to generate a report containing three columns: Name, Grade and Mark.

www.hackerrank.com

 

- join 할 때, between 사용

- order by 할 때, case when 조건 사용

select s.id,
 (case when g.grade <8 then "NULL" else s.stu_name end) as student_name,
 s.marks,
 g.grade
from students s
inner join grades g 
on s.marks between g.min_mark and g.max_mark
order by g.grade desc,
case
	when g.grade < 8 then s.stu_name else marks end;
728x90