Im between cherry

Hackerrank | MySQL | Higher Than 75 Marks 본문

데이터분석/practice_query

Hackerrank | MySQL | Higher Than 75 Marks

meal 2020. 8. 28. 09:22

Higher Than 75 Marks

Problem

 

Higher Than 75 Marks | HackerRank

Query the names of students scoring higher than 75 Marks. Sort the output by the LAST three characters of each name.

www.hackerrank.com

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.

 

- Solution

SELECT name
FROM students
WHERE marks > 75
ORDER BY RIGHT(name, 3) ASC, id ASC
SELECT name
FROM students
WHERE marks > 75
ORDER BY RIGHT(name, 3), ID ASC
SELECT Name
FROM Students
WHERE Marks > 75
ORDER BY right(Name,3), Id
Comments