您好,登錄后才能下訂單哦!
如下圖,統計某一時間段請假類別為Kj_tx 積休假、Kj_nj年假的天數綜合 并按列顯示
select?
a.AlEmpID as 員工ID,
a.alsdate,
a.aledate,
AlTime=(
case when a.ALSTime=480 and a.ALETime=1050 then 1?
? ? ?when a.ALSTime=480 and a.ALETime=720? then 0.5?
? ? ?when a.ALSTime=840? and a.ALETime=1050 then 0.5?
? ? ?when a.ALSTime=870? and a.ALETime=1050 then 0.5?
? ? ? else 0 end) ,
a.ALFType as 請假類別
from? kq_askleave a?
where a.AlEmpID=734 and a.alsdate>='2018-03-01 00:00:00'
select?
aa.員工ID,
max(d.Dept_lname) as 科室,
max(b.Emp_code) as 工號,
max(b.Emp_name) as 姓名,
max(b.Emp_zhiweiname) as 職位,
isnull(sum(case when? aa.請假類別 ='Kj_nj' then aa.AlTime+AlDay end ),0) 年假,
isnull(sum(case when? aa.請假類別 ='Kj_sj' then aa.AlTime+AlDay end ),0) 事假,
isnull(sum(case when? aa.請假類別 ='Kj_bj' then aa.AlTime+AlDay end ),0) 病假,
isnull(sum(case when? aa.請假類別 ='Kj_cj' then aa.AlTime+AlDay end ),0) 產假,
isnull(sum(case when? aa.請假類別 ='Kj_hj' then aa.AlTime+AlDay end ),0) 婚假,
isnull(sum(case when? aa.請假類別 ='Kj_tx' then aa.AlTime+AlDay end ),0) 積休假
from?
(select?
a.AlEmpID as 員工ID,
a.alsdate,
a.aledate,
AlDay=(
case when a.ALSTime=480 and a.ALETime=1050? then datediff(day,a.alsdate,a.aledate)+1?
? ? ?when a.ALSTime=480 and a.ALETime=720? then? datediff(day,a.alsdate,a.aledate)
? ? ?when a.ALSTime=840? and a.ALETime=1050 then datediff(day,a.alsdate,a.aledate)?
? ? ?when a.ALSTime=870? and a.ALETime=1050 then datediff(day,a.alsdate,a.aledate)?
? ? ? else 0 end) ,
AlTime=(
case when a.ALSTime=480 and a.ALETime=1050 then 0?
? ? ?when a.ALSTime=480 and a.ALETime=720? then 0.5?
? ? ?when a.ALSTime=840? and a.ALETime=1050 then 0.5?
? ? ?when a.ALSTime=870? and a.ALETime=1050 then 0.5?
? ? ? else 0 end) ,
a.ALFType as 請假類別
from? kq_askleave a?
where a.AlEmpID=734 and a.alsdate>='2016-11-01 00:00:00' and a.aledate<='2018-05-01 00:00:00') aa
left join employeeview b on aa.員工ID=b.emp_id?
left join kq_altype c on aa.請假類別=c.kqaltcode?
left join emp_department d on b.Dept_code=d.Dept_code
group by? aa.員工ID
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。