Leetcode DataBase

182. Duplicate Emails

select distinct(p1.Email) from Person as p1 where p1.Email in (select p2.Email from Person as p2 where p2.id != p1.id);

751 ms


select distinct(p1.Email) from Person as p1, Person as p2 where (p1.Id != p2.Id and p1.Email = p2.Email);

651 ms



Employees Earning More Than Their Managers

SELECT Name AS Employee From Employee as T1 Where T1.Salary >(SELECT Salary FROM Employee AS T2 WHERE T2.Id = T1.ManagerId);

1282 ms


SELECT T1.Name AS Employee From Employee AS T1, Employee AS T2 WHERE T1.ManagerId = T2.Id AND T1.Salary > T2.Salary;

911 ms


Combine Two Tables

select Person.FirstName, Person.LastName, Address.City, Address.State from Person Left JOIN Address ON Person.PersonId = Address.PersonId;



Customers Who Never Order

SELECT Name AS Customers FROM Customers WHERE Id Not In (SELECT Customers.Id From Customers,Orders WHERE Customers.Id = Orders.CustomerId);


Rising Temperature

SELECT T1.Id FROM Weather AS T1,Weather AS T2 WHERE T1.Date =ADDDATE(T2.Date,1) AND T1.Temperature > T2.Temperature;
<span style="font-family: Arial, Helvetica, sans-serif;">SELECT wt1.Id </span>
FROM Weather wt1, Weather wt2
WHERE wt1.Temperature > wt2.Temperature AND 
      TO_DAYS(wt1.DATE)-TO_DAYS(wt2.DATE)=1;


 

Second Highest Salary


Delete Duplicate Emails



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值