MYSQL/HakerRank_Easy
Higher Than 75 Marks
수스리
2025. 4. 3. 09:20
문제
Query the Name of any student in STUDENTS who scored higher than 75 Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.
점수가 75점이 넘는 학생들 이름을 쿼리하라. 출력 결과는 각 이름의 마지막 세글자를 기준으로 정력하라. 만약 두명이상의 학생 이름이 같은 세 글자로 끝날 경우, ID를 기준으로 오름차순 정렬하라.
SELECT Name
FROM STUDENTS
WHERE Marks > 75
ORDER BY RIGHT(Name, 3), ID
여기서 처음보는 문법을 발견했다. RIGHT 문법이다. RIGT는 내가 지정한 컬럼의 오른쪽에서 3글자를 추출하여 정렬의 기준으로 사용한다. SELECT, ORDERBY등 다양한 문법에서 활용 할 수 있다.