Basic Select
Higher Than 75 Marks
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 ํจ์์ ๋ํ ์ฌ์ฉ๋ฒ
SUBSTR(๋ฌธ์์ด, ์์์์น) : ์์ ๊ธฐ์ค์ผ๋ก ์์์์น๋ถํฐ ๋๊น์ง ์๋ฅด๊ธฐ
SUBSTR(๋ฌธ์์ด, ์์์์น, ๊ธธ์ด) : ์์ ๊ธฐ์ค์ผ๋ก ์์์์น๋ถํฐ ๊ธธ์ด๋งํผ ์๋ฅด๊ธฐ
SUBSTR(๋ฌธ์์ด, ์์์์น(์์)) : ๋ค๋ฅผ ๊ธฐ์ค์ผ๋ก ์์์์น๋ถํฐ ๋๊น์ง ์๋ฅด๊ธฐ
SUBSTR(๋ฌธ์์ด, ์์์์น(์์), ๊ธธ์ด) : ๋ค๋ฅผ ๊ธฐ์ค์ผ๋ก ์์์์น๋ถํฐ ๊ธธ์ด๋งํผ ์๋ฅด๊ธฐ
Employee Names
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?