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
select Person.FirstName, Person.LastName, Address.City, Address.State from Person Left JOIN Address ON Person.PersonId = Address.PersonId;
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