Basic Select

Higher Than 75 Marks

https://www.hackerrank.com/challenges/more-than-75-marks/problem?isFullScreen=true&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen

The STUDENTS table is described as follows:

The Name column only contains uppercase (A-Z) and lowercase (a-z) letters.

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, LENGTH(NAME)-2, 3), ID;
##์œ„์—์„œ ์‚ฌ์šฉํ•ด๋ดค๋˜ substr์„ ์‚ฌ์šฉํ•ด์„œ ์ฒ˜์Œ์—๋Š” ์ ‘๊ทผ
------------------------------------------------------------
SELECT NAME FROM STUDENTS
WHERE MARKS>75
ORDER BY SUBSTR(NAME, -3), ID;

Oracle์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” SUBSTR ํ•จ์ˆ˜์— ๋Œ€ํ•œ ์‚ฌ์šฉ๋ฒ•

  1. SUBSTR(๋ฌธ์ž์—ด, ์‹œ์ž‘์œ„์น˜) : ์•ž์„ ๊ธฐ์ค€์œผ๋กœ ์‹œ์ž‘์œ„์น˜๋ถ€ํ„ฐ ๋๊นŒ์ง€ ์ž๋ฅด๊ธฐ

  2. SUBSTR(๋ฌธ์ž์—ด, ์‹œ์ž‘์œ„์น˜, ๊ธธ์ด) : ์•ž์„ ๊ธฐ์ค€์œผ๋กœ ์‹œ์ž‘์œ„์น˜๋ถ€ํ„ฐ ๊ธธ์ด๋งŒํผ ์ž๋ฅด๊ธฐ

  3. SUBSTR(๋ฌธ์ž์—ด, ์‹œ์ž‘์œ„์น˜(์Œ์ˆ˜)) : ๋’ค๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์‹œ์ž‘์œ„์น˜๋ถ€ํ„ฐ ๋๊นŒ์ง€ ์ž๋ฅด๊ธฐ

  4. SUBSTR(๋ฌธ์ž์—ด, ์‹œ์ž‘์œ„์น˜(์Œ์ˆ˜), ๊ธธ์ด) : ๋’ค๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์‹œ์ž‘์œ„์น˜๋ถ€ํ„ฐ ๊ธธ์ด๋งŒํผ ์ž๋ฅด๊ธฐ

Employee Names

https://www.hackerrank.com/challenges/name-of-employees/problem?isFullScreen=true&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen

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

Input Format

The Employee table containing employee data for a company is described as follows:

where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is their monthly salary.

SELECT name
FROM employee
ORDER BY name;

๋„ค....

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 2000$ per month who have been employees for less than 10 months. Sort your result by ascending employee_id.

SELECT NAME
FROM (
    SELECT *
    FROM EMPLOYEE
    WHERE SALARY > 2000
)
WHERE MONTHS<10
ORDER BY EMPLOYEE_ID;

-----------------------------------------
SELECT NAME
FROM EMPLOYEE
WHERE SALRAY>2000 AND MONTHS<10
ORDER BY EMPLOYEE_ID;

GOOD!

Last updated

Was this helpful?