求救一条删除重复的sql语句
SELECT *
FROM User_Property a
WHERE ((SELECT COUNT(property_mall_ID)
FROM User_Property
WHERE property_mall_ID=a.property_mall_ID and User_Property_UserName = a.User_Property_UserName)>1 )
ORDER BY User_Property_UserName DESC
delete from User_Property where id in
(
select id from
(
(
SELECT dense_rank() OVER (partition BY username+property_mall_ID ORDER BY property_mall_ID
ASC) AS AId,id from User_Property
)
) t where t.aid<>1
)
delete from ax
where id
[解决办法]
username
[解决办法]
property_mall_id in
(select id
[解决办法]
username
[解决办法]
property_mall_id
from (select id,
username,
property_mall_id,
row_number() over(partition by username, property_mall_id order by id) rn
from ax)
where rn <> '1');
ID USERNAME PROPERTY_MALL_ID ROWID
---------- -------- ---------------- ------------------
1 aaaa 1 AAASRaAAGAAAAYbAAA
3 aaaa 2 AAASRaAAGAAAAYbAAC
5 bbbb 1 AAASRaAAGAAAAYbAAE
7 cccc 5 AAASRaAAGAAAAYbAAG
[解决办法]
delete from User_Property where id not in
(
select min(id) from User_Property group by username
)
[解决办法]
delete from 表名 where id not in
(select min(id) from 表名 group by property_mall_ID)