日期:2014-05-17 浏览次数:20540 次
GO
INSERT INTO [tb]
SELECT
1 ,'张三', '2012-09-09 20:10' UNION ALL SELECT
2 ,'李四', '2012-09-07 12:12' UNION ALL SELECT
3 ,'王五', '2012-09-09 09:30' UNION ALL SELECT
4 ,'余六', '2012-09-07 10:30' UNION ALL SELECT
5 ,'姜七', '2012-09-06 11:13' UNION ALL SELECT
6 ,'李八', '2012-09-08 19:20' UNION ALL SELECT
7 ,'邓九', '2012-09-08 23:10' UNION ALL SELECT
8 ,'杜十', '2012-09-05 18:40'
SELECT * FROM [tb] a WHERE NOT EXISTS(SELECT 1 FROM [tb] WHERE ( CONVERT(CHAR(10),a.chekInTime,120)=CONVERT(CHAR(10),chekInTime,120)) AND a.chekInTime <chekInTime)
/*
id name chekInTime
----------- ---------- -----------------------
1 张三 2012-09-09 20:10:00.000
2 李四 2012-09-07 12:12:00.000
5 姜七 2012-09-06 11:13:00.000
7