[HackerRank] Higher Than 75 Marks

당당·2023년 7월 12일
0

HackerRank

목록 보기
1/27
post-thumbnail

https://www.hackerrank.com/challenges/more-than-75-marks/problem

📔문제

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.

The STUDENTS table is described as follows:
The Name column only contains uppercase (A-Z) and lowercase (a-z) letters.


📝예시

Ashley
Julia
Belvet

Only Ashley, Julia, and Belvet have Marks > . If you look at the last three characters of each of their names, there are no duplicates and 'ley' < 'lia' < 'vet'.


🧮분야

  • String

📃SQL 코드

select name
from students
where marks>75
order by substr(name,-3,3),id;

📰출력 결과


📂고찰

조건은 marks가 75보다 큰 학생들을 뽑아야 한다.
정렬은 name의 마지막 3글자 순으로 하고 그것도 같다면 id로 정렬하면 된다.
마지막 3글자는 substr(문자열,-3,3)으로 추출할 수 있다.

https://github.com/dangdangs0/HackerRank

이전까지 풀었던 HackerRank는 여기있다.

profile
MySQL DBA 신입

0개의 댓글