select a.card_no,a.name,a.door_no,b.inout_time from tablename a join ( select card_no,door_no,min(inout_time) group by card_no,door_no) b on a.card_no=b.card_no and a.door_no=b.door_no and a.inout_time=b.inout_time
order by 时间?但我只要最早进入公司的那条记录,一个人一天之内是会多次 进出公司的。我现在还是没有找到合适的SQL语句来做。
你的表建立有 id 字段,如果在同一天里面,时间靠后的 id 值 大 的话 就很好办了将时间等效idselect * form tbl where id in (select min(id) group by 日期)
select * from tbl where id in (select min(id) from tbl group by 日期)
select 卡号,人名,日期 from 考勤表 distinct也可以用索引来做:(VFP中的)
index on 日期 tag rq
然后设置此索引为主控索引即可。
CardNo HolderName IODate IOTime IOGateNo
0003 abcccc 2002-7-3 08:51:30 02-1
0003 abcccc 2002-7-3 09:15:20 02-1
0003 abcccc 2002-7-4 09:05:20 02-1 一个人一天之内可能多次出入大门,但我只要最早的那条记录。我该怎么写
卡号 人名 日期 时间 门号
0003 abcccc 2002-7-3 09:05:20 02-1
0003 abcccc 2002-7-3 09:15:20 02-1
0003 abcccc 2002-7-4 09:15:20 02-1 一个人一天之内可能多次出入大门,我只需要时间最早的那条记录,该怎么办??
选出来就是最早的一条啊。
select card_no,door_no,min(inout_time) group by card_no,door_no) b
on a.card_no=b.card_no and a.door_no=b.door_no and a.inout_time=b.inout_time
进出公司的。我现在还是没有找到合适的SQL语句来做。