delete的⽤法(Hive)(SQL)
此题需要注意的是题⽬要求是删除,故⽽不能使⽤group by,来查询解法如下,采⽤窗⼝函数
delete from Person
where Id
in
(
select
t1.Id
from(
select
Id,Email,
row_number()over(partition by Email order by Id) rn
from Person
) t1
>1
);
不采⽤窗⼝函数的解法
⾸先查询出要删除的数据
SELECT p1.*
FROM Person p1,
sql中delete用法Person p2
WHERE
p1.Email = p2.Email AND p1.Id > p2.Id ;
然后删掉
DELETE p1.* FROM Person p1,
Person p2
WHERE
p1.Email = p2.Email AND p1.Id > p2.Id ;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论