17,377
社区成员
发帖
与我相关
我的任务
分享
select 部门名称,员工名称,count(打卡时间) 考勤次数
from 考勤记录表 a
where not exists(select 1 from 考勤记录表 b where a.部门名称=b.部门名称
and a.员工名称=b.员工名称
and to_char(a.打卡时间,'yyyy-mm-dd')=to_char(b.打卡时间,'yyyy-mm-dd')
and a.打卡时间<b.打卡时间)
group by 部门名称,员工名称
---报下运行时间
create index idx_no on 考勤记录表(部门名称,员工名称)
--或者这样
select 部门名称,员工名称,count(打卡时间) 考勤次数
from 考勤记录表 a
where not exists(select 1 from 考勤记录表 b where a.部门名称=b.部门名称
and a.员工名称=b.员工名称 and a.打卡时间<b.打卡时间)
group by 部门名称,员工名称
select 部门名称,员工名称,count(1)
from (select distinct 部门名称,员工名称,to_char(打卡时间,'yyyy-mm-dd') from 考勤记录表)
group by 部门名称,员工名称