除法
計算財富 500 強公司依產業別的每位員工平均營收。
本練習屬於課程
SQL 中的探索式資料分析
練習說明
- 以
revenues除以employees計算每位員工營收;此處使用轉型以取得數值結果。 - 使用
avg()取每位員工營收的平均,並將其別名為avg_rev_employee。 - 依
sector分組。 - 依每位員工平均營收排序。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
-- Select average revenue per employee by sector
SELECT ___,
___(___/___::numeric) AS avg_rev_employee
FROM fortune500
GROUP BY ___
-- Use the column alias to order the results
ORDER BY ___;