当前位置: 代码迷 >> VFP >> 小弟我用vf6编写了个程序 现在想在一个表中判断是否有重复数据并删除重复数据 请教该如何做
  详细解决方案

小弟我用vf6编写了个程序 现在想在一个表中判断是否有重复数据并删除重复数据 请教该如何做

热度:9255   发布时间:2013-02-26 00:00:00.0
我用vf6编写了个程序 现在想在一个表中判断是否有重复数据并删除重复数据 请问该怎么做?
我用vf6编写了个程序 现在想在一个表中判断是否有重复数据并删除重复数据 请问该怎么做?

我的表名称为JBDATA 其中有XM ZH DW DWCP XH 等字段 现在想依据ZH字段把重复数据筛选掉并把筛选后的数据保存在本表中 请问改怎么做?
数据表内容如下
XM ZH DW DWCP XH
a 1 qw 2 1
b 2 re 1 2
c 3 rt 1 3
a 1 qw 2 4
b 2 re 1 5


请问该怎么操作 谢谢!!!!!!!!!!!

------解决方案--------------------------------------------------------
use jbdata
index on zh to sy
total on zh to 新表名 fileds dw
*--新表名为结果表

------解决方案--------------------------------------------------------
假设以XH最小的为准:
vfp9:
select a.* into newtt from tt a inner join
(select zh,xm,dw,dwcp,min(xh) as ma from tt group by zh,xm,dw,dwcp) b
on a.zh=b.zh and a.xm=b.xm and a.dw=b.dw and a.dwcp=b.dwcp and a.xh=b.ma

DELETE tt from ;
(select zh,xm,dw,dwcp,min(xh) as ma from tt group by zh,xm,dw,dwcp) as b;
where (tt.zh=b.zh and tt.xm=b.xm and tt.dw=b.dw and tt.dwcp=b.dwcp and tt.xh<>b.ma)

  相关解决方案