SELECT name
FROM students
WHERE marks > 75
ORDER BY RIGHT(name, 3), id
느낀 점 및 정리 ✍️
1. "Order your output by the last three characters of each name" => RIGHT(name, 3) 을 사용해서 이름의 가장 오른쪽에 있는 문자 3개를 추출하여 정렬했다.
2. "names ending in the same last three characters, secondary sort them by ascending ID" => 문자 3가지가 동일할 경우 id 오름차순 정렬
'Algorithm & SQL > HackerRank' 카테고리의 다른 글
[HakerRank / MySQL] African Cities (0) | 2024.03.10 |
---|---|
[HackerRank / MySQL] Type of Triangle (0) | 2024.03.10 |
[HackerRank / MySQL] Top Earners (0) | 2024.03.10 |
[HackerRank / MySQL] Revising Aggregations - Averages (0) | 2024.03.10 |
[HackerRank / MySQL] Weather Observation Station 15 (0) | 2024.03.09 |