上传的图像用于项目: 'CST技术支持'
  1. CST技术支持
  2. SLAL2-4829

【Pro-重庆利宝】员工人头报表sql数据集

XMLWord打印

    • C-重庆利宝-
    • PRO
    • 基础通用功能
    • 隐藏
      with date_range as (with recursive
          t(n) as (
              select date('2020-01-01')
              union all
              select n+1 from t where n <= current_date
          )
      select distinct to_char(t.n,'yyyy-mm-25')::date the_date from t)
      select 
      case when position('A' in hr_division.code)=1 then '总公司' else coalesce(hr_division_trans.value,hr_division.name) end 分部,
      to_char(date_range.the_date,'yyyy-mm') 月份,
      coalesce(employee_type_trans.value,employee_type.name) 员工类型,
      count(distinct emp.id) 人数
       from date_range
      left join hr_employee emp
      left join emp_job on emp_job.employee_id=emp.id
      on emp.hire_date<=date_range.the_date and date_range.the_date<=coalesce(emp.termination_date,current_date)
      left join employee_type on emp_job.employee_type=employee_type.id
      left join ir_translation employee_type_trans on employee_type_trans.res_id=employee_type.id
      and employee_type_trans.name ='employee.type,name' 
      and employee_type_trans.lang='zh_CN'
      left join hr_division on emp_job.division_id =hr_division.id
      left join ir_translation hr_division_trans on hr_division_trans.res_id=hr_division.id
      and hr_division_trans.name ='hr.division,name' 
      and hr_division_trans.lang='zh_CN'
      
      where emp.active=True and
            emp_job.eroad_index_id IS NOT NULL AND
                                    
                  emp_job.eroad_start_date <= date_range.the_date AND
                  (emp_job.eroad_end_date >= date_range.the_date OR emp_job.eroad_end_date IS NULL) AND
                  emp_job.status = 'active' AND
                  emp_job.active = TRUE AND
                  emp_job.employee_id IS NOT NULL
      and emp_job.employee_status=2
      group by to_char(date_range.the_date,'yyyy-mm'),coalesce(employee_type_trans.value,employee_type.name),case when position('A' in hr_division.code)=1 then '总公司' else coalesce(hr_division_trans.value,hr_division.name) end
      order by to_char(date_range.the_date,'yyyy-mm') asc
      
      显示
      with date_range as (with recursive t(n) as ( select date( '2020-01-01' ) union all select n+1 from t where n <= current_date ) select distinct to_char(t.n, 'yyyy-mm-25' )::date the_date from t) select case when position( 'A' in hr_division.code)=1 then '总公司' else coalesce(hr_division_trans.value,hr_division.name) end 分部, to_char(date_range.the_date, 'yyyy-mm' ) 月份, coalesce(employee_type_trans.value,employee_type.name) 员工类型, count(distinct emp.id) 人数 from date_range left join hr_employee emp left join emp_job on emp_job.employee_id=emp.id on emp.hire_date<=date_range.the_date and date_range.the_date<=coalesce(emp.termination_date,current_date) left join employee_type on emp_job.employee_type=employee_type.id left join ir_translation employee_type_trans on employee_type_trans.res_id=employee_type.id and employee_type_trans.name = 'employee.type,name' and employee_type_trans.lang= 'zh_CN' left join hr_division on emp_job.division_id =hr_division.id left join ir_translation hr_division_trans on hr_division_trans.res_id=hr_division.id and hr_division_trans.name = 'hr.division,name' and hr_division_trans.lang= 'zh_CN' where emp.active=True and emp_job.eroad_index_id IS NOT NULL AND emp_job.eroad_start_date <= date_range.the_date AND (emp_job.eroad_end_date >= date_range.the_date OR emp_job.eroad_end_date IS NULL) AND emp_job.status = 'active' AND emp_job.active = TRUE AND emp_job.employee_id IS NOT NULL and emp_job.employee_status=2 group by to_char(date_range.the_date, 'yyyy-mm' ),coalesce(employee_type_trans.value,employee_type.name), case when position( 'A' in hr_division.code)=1 then '总公司' else coalesce(hr_division_trans.value,hr_division.name) end order by to_char(date_range.the_date, 'yyyy-mm' ) asc

      员工人头报表
      报表1:需要按分部及员工类型分类统计每月在职人数

      sql数据集需要查询字段:
      分部(分部名称含分公司的,分部名称就为‘’XX分公司‘’,名称不含分公司,分部名称则为‘’总公司‘’),员工类型,月份字段,每月在职人数(取每月25号的在职人数)

            grant.yang 杨光磊
            zhiling.lv 吕致伶
            表决:
            0 为这个问题表决

              创建日期:
              已更新:
              已解决:

                预估时间:
                初始预估 - 尚未指定
                尚未指定
                剩余:
                剩余的估算 - 0小时
                0小时
                实际工作时间:
                耗费时间 - 3小时
                3小时