문제
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.
Sample Input
코드
SELECT name
FROM Employee
ORDER BY name
풀이
- Employee 테이블에서 name 조회
- name의 알파벳 순으로 정렬
ORDER BY 에서 오름차순 정렬은 디폴트 값이기 때문에 컬럼명 뒤에 적지 않아도 됨
내림차순일 경우 DESC 기재
반응형
'Algorithm > MySQL' 카테고리의 다른 글
[해커랭크(HackerRank)] Higher Than 75 Marks (MySQL) (0) | 2021.06.28 |
---|---|
[해커랭크(HackerRank)] Employee Salaries (MySQL) (0) | 2021.06.28 |
[해커랭크(HackerRank)] Weather Observation Station 12 (MySQL) (0) | 2021.06.28 |
[해커랭크(HackerRank)] Weather Observation Station 6 (MySQL) (0) | 2021.06.28 |
[해커랭크(HackerRank)] Select By ID (MySQL) (0) | 2021.06.28 |