select * from 表 a
where 考勤时间=(
select min(考勤时间) from 表
where 卡号=a.卡号
and datediff(day,考勤时间,a.考勤时间)=0
and convert(varchar,考勤时间,108) between '07:00:00' and '08:00:00'
)
where 考勤时间=(
select min(考勤时间) from 表
where 卡号=a.卡号
and datediff(day,考勤时间,a.考勤时间)=0
and convert(varchar,考勤时间,108) between '07:00:00' and '08:00:00'
)
having convert(varchar,考勤时间,108)>='7:00:00' and convert(varchar,考勤时间,108)<=8:00:00