以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何用代码删除重复的内容行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=186147)

--  作者:moseser
--  发布时间:2023/4/9 11:33:00
--  [求助]如何用代码删除重复的内容行
如何删除重复数据

  客户   省份   订货量   订货时间    
   A  山东    2   1月   
   B   山西   4   2月   
   A   山东   2   1月   
   B   山西   4   2月   
数据库里面有类似的重复数据,我该怎么把重复的数据删掉后只留下一条。

--  作者:有点蓝
--  发布时间:2023/4/9 20:21:00
--  
dim t as trable = tables("A")
t.sort = "列1,列2,..."
for i as integer = t.rows.count - 1 to 1 step -1
if t.rows(i)("列1") =  t.rows(i-1)("列1") andalso t.rows(i)("列2") =  t.rows(i-1)("列2") andalso .....
t.rows(i).delete
end if
next