#104. [LeetCode / MySQL] 1731. The Number of Employees Which Report to Each Employee

문제

 

입력 코드

SELECT 
    e2.employee_id, e2.name, 
    COUNT(*) AS reports_count, 
    ROUND(AVG(e1.age)) AS average_age
FROM Employees AS e1
    INNER JOIN Employees AS e2
    ON e1.reports_to = e2.employee_id 
GROUP BY e2.employee_id, e2.name
ORDER BY e2.employee_id

 

 

코드 설명

#SELECT #COUNT #ROUND #AVG #INNER JOIN #GROUP BY #ORDER BY

 

 

문제 출처

 

LeetCode - The World's Leading Online Programming Learning Platform

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com