求一考勤相关的SQl语句。。。

spring11 2005-11-22 12:50:15
员工考勤记录表
ID cardid checktime
527 0000883229 2005-11-13 20:09:56
528 0000890452 2005-11-17 0:08:28
529 0000883229 2005-11-17 22:02:51
530 0000877133 2005-11-17 22:02:54
531 0000890452 2005-11-17 22:02:57
532 0000883229 2005-11-17 22:03:07
533 0000877133 2005-11-17 22:03:07
534 0000890452 2005-11-17 22:03:08

员工信息表
cardID NAME
0000883229 张三
0000877133 李四

要求:列出指定日期内,未参与考勤和只有一次考勤的员工(正常为2次考勤)
...全文
137 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
brooks105 2005-11-22
  • 打赏
  • 举报
回复
select * from 员工信息表
where cardid in
(select cardid from 员工考勤记录表
where checktime between '2005-11-1' and '2005-12-31'
group by cardid
having count(1)<2)
bugchen888 2005-11-22
  • 打赏
  • 举报
回复
正常为两次是指在指定日期内每天两次,还是在指定日期内总共两次?
amtyuranus 2005-11-22
  • 打赏
  • 举报
回复
用having!!

select cardid,count(*) from where group by having
zjcxc 2005-11-22
  • 打赏
  • 举报
回复
select * from 员工信息表 a
where (
select count(*) from 员工考勤记录表
where cardid =a.cardid
and checktime between '2005-11-13' and '2005-12-1'
)<2
spring11 2005-11-22
  • 打赏
  • 举报
回复
在邹老大的热心关注下,偶滴考勤系统一定会圆满滴完成的。
SQL菜鸟在各位的热心关怀下不断滴成长。。。放分!!

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧