開始使用免費開始

除法

計算財富 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 ___;
編輯並執行程式碼