假设表结构:用户名,日期,上班时间,下班时间。
8月份记录:
select * from 表名 where month(日期)=8 and 用户名 = '小张'
8月份迟到早退次数:
select sum(iif(datediff('s','8:00',上班时间) > 0,1,0)) as 迟到次数,sum(iif(datediff('s','17:00',下班时间) < 0,1,0)) as 早退次数 from 表名 where month(日期) = 8 and 用户名 = '小张'

select * from database where DATEPART(YEAR,date) = 2012 and MONTH(date) = 3
查询年用datapart,月用month,上面的sql语句是查询2012年3月的数据,就是这么简单粗暴

 

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2021-08-16
  • 2022-12-23
  • 2021-11-18
  • 2021-12-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案