当前位置:首页 » 编程语言 » 连续打卡天数sql
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

连续打卡天数sql

发布时间: 2022-06-05 11:48:08

1. 请用sql实现查询出每个员工2019年10月份上班打卡次数,并按打卡次数从大到小排序卡次数从大到小排序

你好,很高兴回答你的问题。
因为没有提供表结构,我就大概描述一下吧。
大致sql结构如下:
select 员工,count(1) from 表名 where 时间条件 group by 员工 order by count(1) desc;
如果有帮助到你,请点击采纳。

2. SQL统计一个月连续出勤6天以上的员工

select 用户ID
from
(select 用户ID,count(*) cnt

from 表名
group by 用户ID
)tbl
where tbl.cnt > 6

3. sql求解:查询连续七天以上都有打卡的员工记录

可以利用一下ORACLE的ROWNUM机制来做点文章,因为它是自增的
我假设有这一张表 WORK
ID,上班日期(DA)
1,20080101
1,20080102
1,20080103
2,20080101
2,20080103
3,20080101
也可能是乱序的
第一步:排序
SELECT * FROM WORK ORDER BY ID, DA
第二步:日期-ROWNUM如果相同的话认为他们是连续的,然后GORUP BY一下
SELECT A.*, TO_NUMBER (A.DA - ROWNUM) DAYS
FROM (SELECT * FROM WORK ORDER BY ID, DA) A
第三步:分别求出连续区间,让他们相减求出大于6的值
SELECT C.ID
(SELECT B.ID, (MAX (B.DA) - MIN (B.DA)) DAYS
FROM (SELECT A.*, TO_NUMBER (A.DA - ROWNUM) DAYS
FROM (SELECT * FROM WORK ORDER BY ID, DA) A) B
GROUP BY B.ID, B.DAYS) C
WHERE C.DAYS > 7

ITPUB一位高人的办法得到了启发

4. 用 sqlserver 怎样查询出 数据表里 某月上班连续打卡15天的人

这个功能数据库用SQL语句是实现不了的,建议把每个月的上班情况读出来,用编程语言通过编程判断。你的需求是属于业务逻辑功能,数据库实现不了这么复杂的功能。

5. 考勤日报表中(卡号,日期,旷工天数,打卡时间),如何用SQL语句查询出连续旷工3天的员工

你没描述得太清楚,不过大概意思明白了,暂定认为你的表里旷工天数为1表示旷工,你要查看的是2009年9月 可以这样写:select distinct 卡号 from 表 t where 旷工天数=1 and year(打卡日期)=2009 and month(打卡日期)=9
and exists(select * from 表 where 卡号=t.卡号 and 旷工天数=1 and 打卡日期=dateadd(d,1,t.打卡日期))
and exists(select * from 表 where 卡号=t.卡号 and 旷工天数=1 and 打卡日期=dateadd(d,2,t.打卡日期)) 返回满足条件员工的卡号

6. sql统计一个月一共出勤多少天

出勤天数
select * from 考勤表 where (intkqstate<7 and outkqstate<7) and 日期 between '2009-1-1' and '2009-1-31' and 员工ID=" & ID
如果不查某个人的,就不用加员工ID这个条件

未出勤天数:
select * from 考勤表 where (intkqstate>6 and outkqstate>6) and 日期 between '2009-1-1' and '2009-1-31' and 员工ID=" & ID

7. SQL 统计每日上班打卡和下班打卡语句

这是在oracle数据库下做的,不知道你是什么数据库,给你提供一下思路
select
card_no,
attr_date,
to_char(atte_time,'HH24:MI')tim,
doorinout,
rn
from (
select
card_no,
attr_date,
atte_time,
doorinout,
ROW_NUMBER() OVER(PARTITION BY card_no,attr_date,doorinout ORDER BY atte_time asc) rn
from(
select
card_no,
(
case
when doorinout=1
then to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')
when (doorinout=0 and to_number(to_char(atte_time,'HH24'))<3)
then (to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')-1)
else to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')
end

)attr_date,
atte_time,
doorinout
from AtteTime
) tmp order by card_no,atte_time asc,doorinout desc
) where rn < 5

8. 请用sql实现查询出每个员工2019年10月份上班打卡次数,并按打卡次数排序

这要是在公司里查,一般公司不让你查这些方面的,除非你和公司的领导关系好。

9. SQL查询连续多少天有刷卡的记录

存储过程/函数/或者程序里算吧
伪码
list = name,date from t where name=n order by date
ignorlist = array()
result = array()
for(i in list)
{
if(i.date not_in ignorlist )
{
d = i.date;
td.start = td.end = d;
while(td.end+1 in list)
{
td.end++
ignorlist.add(td.end)
}
result.add(td)
}
}