如下圖,統(tǒng)計某一時間段請假類別為Kj_tx 積休假、Kj_nj年假的天數(shù)綜合 并按列顯示
成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站建設、成都網(wǎng)站設計與策劃設計,阜新網(wǎng)站建設哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設十年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:阜新等地區(qū)。阜新做網(wǎng)站價格咨詢:13518219792
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) 產(chǎn)假,
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
當前名稱:按某一列里面同一類橫向顯示數(shù)據(jù)總數(shù)
標題鏈接:http://www.rwnh.cn/article12/psjcgc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、動態(tài)網(wǎng)站、品牌網(wǎng)站設計、外貿(mào)建站、定制開發(fā)、標簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)