请指教 ,ACCESS中的语句!
在表1中,有四个字段 ID time ccd1 ccd2 共有几千条记录,现在因为在保存的时候,相邻两条记录中,time有间断的现象,比如 23 14:12:12 34 35
24 14:12:13 45 67
25 14:24:18 54 56
26 14:24:19 33 34
27 14:24:20 34 54
28 14:24:21 33 43
我该如何找到这个间断点如ID=24呢?
问题点数:10、回复次数:4Top
1 楼zuchunguang(光光)回复于 2005-07-03 23:00:54 得分 0
里面还有一些重复的记录,如何找到time 字段重复的记录ID呢
Top
2 楼beyondtkl(大龙驹<*好久没来了,兄弟们好吧。*>)回复于 2005-07-04 09:14:22 得分 0
判断 ID重复 看用子查询行不
Top
3 楼feitianbianfu16()回复于 2005-07-04 09:51:19 得分 0
1.你说的间断是以多长的时间为间断呢?
2.重复的记录:
select b.* from 表1 b where b.time=(select a.time from 表1 a where a.time=b.time and a.id<>b.id)Top
4 楼vivianfdlpw()回复于 2005-07-04 11:02:19 得分 0
--创建测试环境
create table #
(
ID int,
[time] varchar(20),
ccd1 int,ccd2 int
)
insert #
select 23,'14:12:12',34,35 union
select 24,'14:12:13',45,67 union
select 25,'14:24:18',54,56 union
select 26,'14:24:19',33,34 union
select 27,'14:24:20',34,54 union
select 28,'14:24:21',33,43 union
select 28,'14:24:21',33,44
-- 测试
select [间断点]=max(ID) from # group by left(time,5)
select * from # A where exists(select 1 from # where [time]=A.[time] group by [time] having count(1)>1)
--删除测试环境
drop table #
--结果
/*
间断点
-----------
24
28
(所影响的行数为 2 行)
ID time ccd1 ccd2
----------- -------------------- ----------- -----------
28 14:24:21 33 43
28 14:24:21 33 44
(所影响的行数为 2 行)
*/Top




