Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

하루에 하나씩 공부하기

[해커랭크-Basic Join] The Report 본문

카테고리 없음

[해커랭크-Basic Join] The Report

dltaexox 2025. 9. 12. 16:00

- 문제

점수별 등급 맞춰 출력하기

 

The Report | HackerRank

 

The Report | HackerRank

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

www.hackerrank.com

 

- 키포인트

어떻게 조인을 해야하지? > CTE 만들고 이상한 짓 함

 

- 쿼리

SELECT 
CASE WHEN G.GRADE>=8 THEN S.NAME
ELSE NULL
END,
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, S.NAME ASC, S.MARKS ASC;

 

그냥 조인 조건에 BETWEEN 넣으면 해결 가능!