평균과 중앙값
Fortune 500 기업의 섹터별 자산의 평균(avg())과 중앙값을 계산하세요.
중앙값 계산에는 percentile_disc() 함수를 사용하세요:
percentile_disc(0.5)
WITHIN GROUP (ORDER BY column_name)
이 연습은 강의의 일부입니다
SQL로 하는 탐색적 데이터 분석
연습 안내
assets의 평균과 중앙값을 선택하세요.sector로 그룹화하세요.- 결과를 평균 기준으로 정렬하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
-- What groups are you computing statistics by?
SELECT ___,
-- Select the mean of assets with the avg function
___ AS mean,
-- Select the median
___(___) ___ ___ (___ ___ ___) AS median
FROM fortune500
-- Computing statistics for each what?
GROUP BY ___
-- Order results by a value of interest
ORDER BY ___;