更正一下:
declare @startdate varchar(30)
declare @enddate varchar(30)
set @startdate = '2007-03-01'
set @enddate = '2007-03-30'
select a.cardid,a.姓名
from 考勤表 a
where not exists(select cardid 卡号,name 姓名
from 考勤表 b
where a.cardid = b.cardid AND
time between @startdate and @enddate AND
convert(char(8),time,108) between '07:50:00' and '10:00:00'
order by time)
declare @startdate varchar(30)
declare @enddate varchar(30)
set @startdate = '2007-03-01'
set @enddate = '2007-03-30'
select cardid,姓名
from 考勤表
where not exists(select cardid 卡号,name 姓名
from 考勤表
where time between @startdate and @enddate AND
convert(char(8),time,108) between '07:50:00' and '10:00:00'
order by time)
CREATE PROCEDURE PROTEST
@BEGINDATE DATETIME,
@ENDDATE DATETIME
AS
SELECT cardid,name,签到时间 = CASE WHEN convert (datetime,RIGHT(CONVERT(CHAR(19),time,120),9)) >= convert (datetime,'7:50') and convert (datetime,RIGHT(CONVERT(CHAR(19),time,120),9)) <= convert (datetime,'10:00') THEN cast(time as varchar) ELSE '未签到' END FROM TB WHERE [time] BETWEEN @BEGINDATE AND @ENDDATE
select
t.*
from
人员表 t
where
not exists(select
1
from
考勤表
where
cardid=t.cardid
and
time between '2007-03-01 00:00:00' and '2007-03-30 23:59:59'
and
convert(char(8),time,108) between '07:50:00' and '10:00:00')