일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- MySQL
- CNN10
- 알고리즘
- Baekjoon
- Udemy
- Joseph Samuel Nye Jr.
- EBS
- 맛집
- Progate
- 자료구조
- 당신이 몰랐던 진화론
- K-MOOC
- python
- 백준
- ADsP
- 후기
- KMOOC
- 데이터분석전문가가이드
- ADP
- 조지프 나이
- Hacker Rank
- 위대한 수업
- 공부정리
- 미분적분학
- 정치학
- 빅데이터
- 누가 진정한 리더인가
- Great Minds
- 데이터분석전문가
- 코테
Archives
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#New Companies 본문
SQL > Advanced Select > New Companies
New Companies | HackerRank
Find total number of employees.
www.hackerrank.com
Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code.
Note:
- The tables may contain duplicate records.
- The company_code is string, so the sorting should not be numeric. For example, if the company_codes are C_1, C_2, and C_10, then the ascending company_codes will be C_1, C_10, and C_2.'
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
SELECT C.COMPANY_CODE, C.FOUNDER, COUNT(DISTINCT E.LEAD_MANAGER_CODE),
COUNT(DISTINCT E.SENIOR_MANAGER_CODE), COUNT(DISTINCT E.MANAGER_CODE),
COUNT(DISTINCT E.EMPLOYEE_CODE)
FROM COMPANY C
JOIN EMPLOYEE E
ON C.COMPANY_CODE = E.COMPANY_CODE
GROUP BY C.COMPANY_CODE, C.FOUNDER
ORDER BY C.COMPANY_CODE ASC
반응형
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#Contest Leaderboard (0) | 2022.03.02 |
---|---|
[Hacker Rank_MySQL]문제 풀이#Symmetric Pairs (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Binary Tree Nodes (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Weather Observation Station 19 (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#The PADS (0) | 2022.03.01 |
Comments