[HackerRank] Basic SELECT S4

Ga0·2023년 9월 2일
0

HackerRank

목록 보기
4/5

문제1 - 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.

SELECT Name
 FROM STUDENTS
 WHERE Marks > 75
 ORDER BY SUBSTR(Name, -3), ID; -- SUBSTR(컬럼, 인덱스) : 컬럼값의 인덱스 값이 (-)이면 뒤에서 부터

문제2 - Employee Names

Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.

SELECT name
 FROM Employee
 order by name;

문제3 - Employee Salaries

Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than per month who have been employees for less than months. Sort your result by ascending employee_id.

SELECT name
 FROM Employee
 WHERE salary > 2000
   AND months < 10
 ORDER BY employee_id;

Basic Select의 완료!!!!

0개의 댓글