Coderbyte SQL - Member Count

미정·2021년 8월 26일
0

Coderbyte | SQL

목록 보기
1/1

✅문제

Your table: maintable_SMU21
MySQL version: 5.5.56-log

In this MySQL challenge, your query should return the names of the people who are reported to (excluding null values), the number of members that report to them, and the average age of those members as an integer. The rows should be ordered by the names in alphabetical order. Your output should look like the following table.

🎹📢입출력 예제

✍풀어보기

SELECT
  ReportsTo,
  COUNT(ReportsTo) AS Members,
  ROUND(AVG(Age)) AS "Average Age"
FROM maintable_SMU21
WHERE ReportsTo IS NOT NULL
GROUP BY ReportsTo
ORDER BY ReportsTo ASC

검색하면서 기능들을 다시 한번 공부하면서 풀었다. AS명령어를 통해 컬럼의 이름을 지정할 수 있다.



참고 자료 및 사이트 (감사합니다)

profile
공사중

0개의 댓글