请教sql高手
10、 有表test
Personcode ttime Iotype
001 8:00 1
001 8:05 1
001 12:00 2
请写SQL语句将两行IOTYPE相同,时间间隔不足10分钟的第二条记录提取出来。
参考答案:SELECT A.*
FROM test A, test B
WHERE A.Iotype = B.Iotype
and datediff('S',A.ttime,B.ttime)<600
and A.kssj>B.kssj;
10、 有表test
Personcode ttime Iotype
001 8:00 1
001 8:05 1
001 12:00 2
请写SQL语句将两行IOTYPE相同,时间间隔不足10分钟的第二条记录提取出来。
参考答案:SELECT A.*
FROM test A, test B
WHERE A.Iotype = B.Iotype
and datediff('S',A.ttime,B.ttime)<600
and A.kssj>B.kssj;