JOIN 연산의 ON 뒤에는 항상 a.id = b.id 와 같이 조건이 와야 한다고 생각했는데, between 연산도 가능하다! 충격!
https://www.hackerrank.com/challenges/the-report/problem?isFullScreen=true
The Report | HackerRank
Write a query to generate a report containing three columns: Name, Grade and Mark.
www.hackerrank.com
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
*/
select (CASE WHEN g.Grade < 8 THEN 'NULL'
ELSE s.Name
END) as name
,g.grade,s.marks
from students s
join grades g on s.marks between g.min_mark and g.max_mark
order by g.grade desc,name asc ;