mySQL

HackerRank - Higher than 75 Marks

bellhundred 2023. 2. 22. 11:03

https://www.hackerrank.com/challenges/more-than-75-marks/problem?isFullScreen=true 

 

Higher Than 75 Marks | HackerRank

Query the names of students scoring higher than 75 Marks. Sort the output by the LAST three characters of each name.

www.hackerrank.com

SELECT NAME
FROM STUDENTS
WHERE MARKS > 75
ORDER BY RIGHT(NAME,3), ID;

WHERE 조건으로 출력 열을 필터링하는 것은 쉽다.

 

이름의 오른쪽 3자리를 기준으로 정렬하고, 그 기준이 같은 경우 ID로 출력하는 부분이 조금 난감했다.

 

RIGHT를 통해 String의 일정 부분만을 가져올 수 있다.