In this HackerRank Higher Than 75 Marks problem solution Query the Name of any student in STUDENTS who scored higher than 75 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.
Problem solution MS SQL.
/* Enter your query here. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error. */ SELECT NAME FROM STUDENTS WHERE MARKS > 75 ORDER BY SUBSTRING(NAME,LEN(NAME)-2,3), ID;
Problem solution in Oracle.
/* Enter your query here. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error. */ select name from students where marks>75 order by substr(name,length(name)-2,3),id; --select * from students;
Problem solution in DB2.
/*
Enter your query here and follow these instructions:
1. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
2. The AS keyword causes errors, so follow this convention: "Select t.Field From table1 t" instead of "select t.Field From table1 AS t"
3. Type your code immediately after comment. Don't leave any blank line.
*/
SELECT NAME FROM STUDENTS WHERE MARKS>75 ORDER BY RIGHT(NAME,3),ID;

0 Comments