일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- 당신이 몰랐던 진화론
- EBS
- 알고리즘
- 데이터분석전문가가이드
- 자료구조
- 조지프 나이
- 맛집
- 공부정리
- 백준
- 코테
- Udemy
- MySQL
- Baekjoon
- 미분적분학
- Joseph Samuel Nye Jr.
- 누가 진정한 리더인가
- ADP
- 빅데이터
- KMOOC
- 정치학
- Progate
- CNN10
- Great Minds
- K-MOOC
- 위대한 수업
- python
- 후기
- 데이터분석전문가
- ADsP
- Hacker Rank
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#The Report 본문
The Report | HackerRank
Write a query to generate a report containing three columns: Name, Grade and Mark.
www.hackerrank.com
Ketty gives Eve a task to generate a report containing three columns: Name, Grade and Mark. Ketty doesn't want the NAMES of those students who received a grade lower than 8. The report must be in descending order by grade -- i.e. higher grades are entered first. If there is more than one student with the same grade (8-10) assigned to them, order those particular students by their name alphabetically. Finally, if the grade is lower than 8, use "NULL" as their name and list them by their grades in descending order. If there is more than one student with the same grade (1-7) assigned to them, order those particular students by their marks in ascending order.
Write a query to help Eve.
Note
Print "NULL" as the name if the grade is less than 8.
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
SELECT
CASE
WHEN G.GRADE > 7
THEN S.NAME
ELSE NULL
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, S.NAME ASC, S.MARKS ASC
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#Top Earners (0) | 2022.02.28 |
---|---|
[Hacker Rank_MySQL]문제 풀이#Ollivander's Inventory (0) | 2022.02.27 |
[Hacker Rank_MySQL]문제 풀이#Top Competitors (0) | 2022.02.27 |
[Hacker Rank_MySQL]문제 풀이#Higher Than 75 Marks (0) | 2022.02.21 |
[Hacker Rank_MySQL]문제 풀이#Weather Observation Station 5 (0) | 2022.02.21 |