select distinct e.name,d.name,
sum(case when datediff(hour,a.inTime,a.outTime)>2 then 1
when 2<datediff(hour,a.inTime,a.outTime)<12 then 1.5
when datediff(hour,a.inTime,a.outTime)>12 then 2
else 0
end)as 下井次数from attendance a ,employee e,department dwhere a.cardNum=e.cardnumber and d.id=e.departmentId
and a.occDay between 20131213 and 20131222
--and datediff(hour,a.inTime,a.outTime)>2
group by e.name,d.name
sum(case when datediff(hour,a.inTime,a.outTime)>2 then 1
when 2<datediff(hour,a.inTime,a.outTime)<12 then 1.5
when datediff(hour,a.inTime,a.outTime)>12 then 2
else 0
end)as 下井次数from attendance a ,employee e,department dwhere a.cardNum=e.cardnumber and d.id=e.departmentId
and a.occDay between 20131213 and 20131222
--and datediff(hour,a.inTime,a.outTime)>2
group by e.name,d.name
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货