根据最大日期/时间删除Oracle中的重复记录 [英] Deleting Duplicate Records in Oracle based on Maximum Date/Time

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

问题描述

我有以下带有重复信息的示例数据:

i have the following sample data with duplicate information:

ID   Date                 Emp_ID    Name    Keep
---------------------------------------------------------
1    17/11/2010 13:45:22  101       AB      *
2    17/11/2010 13:44:10  101       AB
3    17/11/2010 12:45:22  102       SF      *
4    17/11/2010 12:44:10  102       SF
5    17/11/2010 11:45:22  103       RD      *
6    17/11/2010 11:44:10  103       RD        

基于上述数据集,如何删除重复的Emp ID,而仅保留指定了最大日期/时间的Emp ID?

Based on the above data set, how can I remove the duplicate Emp IDs and only keep the Emp IDs that have the maximum date/time specified?

因此,根据以上内容,我只会看到ID:1、3和5.

So based on the above, I would only see IDs: 1, 3 and 5.

谢谢.

推荐答案

类似的东西

DELETE FROM the_table_with_no_name 
WHERE date_column != (SELECT MAX(t2.date_column) 
                      FROM the_table_with_no_name t2 
                      WHERE t2.id = the_table_with_no_name.id);

这篇关于根据最大日期/时间删除Oracle中的重复记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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