QUIZ

Query the Name of any student in STUDENTS who scored higher than  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.

 

MY ANSWER

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

 

POINT

문자를 잘라야하는 경우에는 세가지만 생각하기 ! ORDER BY에서도 쓸 수 있다 :) 

  • SUBSTRING(문자열, 시작위치, 길이)
  • LEFT(문자열, 길이)
  • RIGHT(문자열, 길이)

+ Recent posts