删除重复小于或等于2的记录 [英] Delete records which repeated less than or equal 2

查看:123
本文介绍了删除重复小于或等于2的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



请告诉我如何删除重复次数少于或等于2次的记录。

以下是选择查询我写信来获取在我的数据库表中重复超过2次的数据



Hi all

Please tell me how to delete records which repeated less than or equal 2 times.
below is the select query i wrote to get the data which repeated more then 2 times in my database table

SELECT count(*) as count, bill_no
FROM transaction_details
GROUP BY bill_no
HAVING COUNT(*) > 2
ORDER BY bill_no;

推荐答案

不确定我的解决方案。如果你想删除重复小于或等于2的记录,那么试试吧这个,

编辑:2

Not Sure with my solution.If you want to delete records which is repeated less than or equal to 2,then try like this,
2
delete from transaction_detailswhere bill_no in (
select b.bill_no from transaction_details as a right join (
SELECT count(*) as count, bill_no
FROM transaction_details
GROUP BY bill_no
HAVING COUNT(*)<=2
) as b on a.bill_no=b.bill_no
);



或者如果你想删除带有count>的记录2,这样做


Or if you want to delete records with count > 2, do like this

delete from transaction_detailswhere bill_no in (
select b.bill_no from transaction_details as a right join (
SELECT count(*) as count, bill_no
FROM transaction_details
GROUP BY bill_no
HAVING COUNT(*)>2
) as b on a.bill_no=b.bill_no
);


这篇关于删除重复小于或等于2的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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