You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECTp.firstName, p.lastName, a.city, a.stateFROM Person p
LEFT JOIN Address a
ONp.personId=a.personId;
181. Employees Earning More Than Their Managers
SELECTe1.nameAS Employee
FROM Employee e1
JOIN Employee e2
ONe1.managerId=e2.idWHEREe1.salary>e2.salary;
182. Duplicate Emails
SELECT email
FROM Person
GROUP BY1HAVINGCOUNT(id)>1;
183. Customers Who Never Order
SELECT name AS Customers
FROM Customers
WHERE id NOT IN
(
SELECT customerId
FROM Orders
GROUP BY1
);
196. Delete Duplicate Emails
DELETEFROM Person
WHERE id NOT IN
(
SELECTMIN(id)
FROM Person
GROUP BY email
);
197. Rising Temprature
-- Option 1 (If all dates are present)SELECT id
FROM
(
SELECT id, temperature, LAG(temperature, 1) OVER (ORDER BY recordDate) AS previous_temperature
FROM Weather
)
WHERE temperature > previous_temperature;
-- Option 2 (If all dates are not present)SELECTw1.idFROM Weather w1
JOIN Weather w2
ONw1.recordDate=w2.recordDate+1WHEREw1.temperature>w2.temperature;