找到在所选日期范围内休假的其他人

时间:2015-10-06 09:34:59

标签: sql postgresql

我需要找出其他人在给定的日期范围内申请休假。我这样想(PostgreSQL)

SELECT
  hel.hrl_id,
  hry_type,
  hep.emp_id,
  hep.emp_code,
  hep.emp_firstname || ' ' || hep.emp_lastname AS NAME,
  hel.hrl_date_from,
  hel.hrl_date_to,
  hel.hrl_no_of_leave,
  hel.hrl_note,
  hel.hrl_applied_date,
  dep_name
FROM
  hr_emp_personal hep
LEFT JOIN hr_emp_official heo ON hep.emp_id = heo.emp_id
LEFT JOIN hr_emp_leave hel ON hep.emp_id = hel.emp_id
LEFT JOIN department_master dep ON heo.hro_department = dep.dep_id
LEFT JOIN hr_yearlyleavemaster hry ON hry.hry_id = hel.hry_id
WHERE
  hep.emp_left = 0
  AND hel.hrl_incharge_approve = 1
  AND hel.hrl_hr_approve = 1
  AND hel.hrl_date_to > CURRENT_DATE
  AND hrl_date_from <= '2015-10-23'
  AND hrl_date_to > '2015-10-26'

我在数据库中有一个从24-10-201527-10-2015的记录。我怎样才能做到这一点?员工需要知道在给定范围内还有谁请假。

0 个答案:

没有答案