[SQL手撕]

Duancf發表於2024-09-11

刪除重複的電子郵箱

delete from Person
where id not in
(select id from
(select min(id) as id from Person
group by email) as temp)

好友申請 II :誰有最多的好友

select id,count(id) as num from
(select requester_id as id from RequestAccepted 
union all
select accepter_id as id from RequestAccepted) as temp
group by id
order by num desc
limit 1

買下所有產品的客戶

select customer_id from Customer 
group by customer_id 
having count(distinct product_key) = (select count(product_key ) from Product )

相關文章