试图找出所有员工的平均就业时间

时间:2017-02-01 00:26:11

标签: sql oracle

将它四舍五入到最近的一年。

GKGameSessionEventListener

到目前为止,我已经能够计算出月数。

我正在使用12c

3 个答案:

答案 0 :(得分:1)

如果你想要平均值,那么你需要聚合:

select avg(months_between(sysdate, start_date) ) as avg_months
from job_history;

如果你想要它多年:

select round(avg(months_between(sysdate, start_date))/12) as avg_years
from job_history;

答案 1 :(得分:0)

这就是它的样子

SELECT AVG(DATEDIFF(year,start_date, end_date)) AS AverageLengthOfEmployment from job_history

答案 2 :(得分:0)

试试这个:

SELECT 
  employee_id
, AVG(CAST( months_between(start_date, sysdate) / 12 AS INTEGER) AS avg_work_years
FROM job_history