새소식

IT/SQL

[해커랭크] Higher Than 75 Marks

  • -
728x90
반응형

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

 

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.

(Marks가 75보다 높은 학생. 이름의 마지막 3글자 정렬. 중복되면 ID로 정렬)

 

Input Format

The STUDENTS table is described as follows: 

 The Name column 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
    • 0이 아닌 1부터 시작
    • ORDER BY SUBSTRING('Kristeen', 1, 4) => Kris

 

ASC가 기본값이지만 적어둠

728x90
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.