根据最近的删除重复项 [英] Removing Duplicates based on most recent

查看:64
本文介绍了根据最近的删除重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我读到对此的回复时,我完全期待有一个片刻......但是......


我在[LN]字段中有一个重复的表(可能是2个具有相同值的记录,可能是7个记录)。我需要根据[eDate]字段删除除最近的所有内容。


我希望这是足够的信息。


谢谢。

I fully expect to have a duh moment when I read replies to this....BUT....

I have a table with duplicates in the [LN] field (could be 2 records with same value, might be 7 records). I need to delete all but the the most recent based on the [eDate] field.

I hope this is enough info.

Thanks.

推荐答案

@ bard777


您的桌子中是否设置了唯一的密钥?


如果是这样,你可以这样做:
@bard777
Do you have a unique key set up in your table?

If so, you could do something like this:
展开 | 选择 | Wrap | 行号


@gershwyn


是的,我有一个ID字段,所以这是一个很好的领导,谢谢。


有可能[eDate]也可以是相同的,但在这种情况下要么会这样做。真正的问题是前端没有数据验证。
@gershwyn
Yes, I have an ID field, so this is a good lead, thanks.

It is possible that [eDate] could be the same as well, but in this case either will do. The real issue is there is no data validation on the front end.


@ bard777


以下函数将打开一个记录集检查两列LN并在名为Table1的表中进行编辑,并按LN的升序和edate的降序堆栈记录。该过程循环记录跳过第一个LN编号(即该LN值的最新日期)并删除堆栈中具有相同LN值的任何其他记录。它会针对在表格末尾找到的每个LN编号重复此过程。最终结果是第一列和第二列中的单个LN值是该LN编号的最新日期。显然在复制表上测试它是否符合您的需求

@bard777
The following function will open a recordset examining two columns LN and edate in a table named Table1 and stack records in Ascending order of LN and descending descending order of edate. The procedure loops records skipping over the first LN number (ie the latest date for that LN value) and deletes any other records having the same LN value in the stack. It repeats this process for each individual LN number found until the end of the table. The end result is an individual LN value in the first column and in the second column the latest date for that LN number. Obviously test this out on a copy table to see if it fits your needs

展开 | 选择 | Wrap < span class =codeDivider> | 行号


这篇关于根据最近的删除重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆