Query theNameof any student inSTUDENTSwho scored higher thanMarks. Order your output by thelast three charactersof 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 ascendingID.
(Marks가 75보다 높은 학생. 이름의 마지막 3글자 정렬. 중복되면 ID로 정렬)
Input Format
TheSTUDENTStable is described as follows:
TheNamecolumn only contains uppercase (A-Z) and lowercase (a-z) letters.
Sample Input
❗답
SELECT NAME
FROM STUDENTS
WHERE MARKS > 75
ORDER BY RIGHT(NAME, 3), ID ASC
🤔풀이
ORDER BY : 정렬(기본값은 오름차순)
ORDER BY는 왼쪽부터 순자척으로 진행됨.
ORDER BY RIGHT(칼럼명 또는 문자열, 문자열의 길이)
ORDER BY RIGHT('Kristeen', 3) => teen
ORDER BY LEFT(칼럼명 또는 문자열, 문자열의 길이)
ORDER BY LEFT('Kristeen', 3) => Kri
ORDER BY SUBSTRING(컬럼명 또는 문자열, 시작 위치, 문자열의 길이) = SUBSTR