# Higher Than 75 Marks

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_.



{% embed url="https://www.hackerrank.com/challenges/more-than-75-marks/problem?isFullScreen=true" %}

Sol:

SELECT Name FROM Students WHERE Marks > 75 ORDER BY RIGHT(Name,3), ID;



Explanation:

This query retrieves the names of students from the Students table where the Marks column value is greater than 75. The results are ordered first by the last three characters of the Name column, and then by the ID column.

* SELECT Name: This part of the query specifies that we want to retrieve the values from the Name column of the Students table.
* FROM Students: This specifies the table from which we want to retrieve the data, which is the Students table.
* WHERE Marks > 75: This is a condition added to the query using the WHERE clause. It filters the rows in the Students table so that only rows where the value in the Marks column is greater than 75 are included in the result.
* ORDER BY RIGHT(Name,3), ID: This part of the query specifies the order in which the results should be sorted. It first orders the results by the last three characters of the Name column (using the RIGHT function to extract the last three characters), and then by the ID column.

So, the query retrieves the names of students with marks greater than 75, ordered first by the last three characters of their names and then by their IDs.
