當前位置:編程學習大全網 - 網站源碼 - SQL語言考勤打卡記錄

SQL語言考勤打卡記錄

首先要有壹個工廠日歷的表,列出所有工作日,至少壹個字段:工作日 varchar(10)。

然後這樣即可:

select id,

遲到次數=sum(case when timec>'08:00:00' tand timec<'09:00:00' then 1 else 0 end),

曠工次數=sum(case when timec>'09:00:00' or timec is null then 1 else 0 end),

打卡次數=sum(case when timec is null then 0 else 1 end)

from

(

SELECT * FROM 工廠日歷 left join

(select id,

datec=convert(varchar(10),card_time,120),

timec=substring(convert(varchar,card_time,120),12,8)

from tablename

) a

on 工作日=DATEC

) b

group by ID

  • 上一篇:如何評價“我在校園”小程序?
  • 下一篇:c語言小問題,還望高手指導指導,下面這個程序我用TC運行結果為205,VC運行結果為403,還沒搞清為什麽。
  • copyright 2024編程學習大全網