SQL leetcode刷題答案(一)

leetcode上刷SQL題的代碼,僅供參考,畢竟答案不唯一,我的代碼執行效率也不是很高

1、Combine Two Tables

select FirstName, LastName, City, State from Person left join Address on Person.PersonId = Address.PersonId

2、Customers Who Never Order

select name as Customers from Customers left join Orders 
on Customers.Id = Orders.CustomerId 
where Orders.CustomerId is null

3、Duplicate Emails

select Email from Person 
group by Email
having count(Email)>1

4、Not Boring Movies

select id,movie,description,rating from cinema 
where (description != 'boring' and id mod 2 = 1)
order by rating desc

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章