題目mysql
# Write your MySQL query statement below SELECT Name AS Customers FROM Customers LEFT JOIN Orders ON Customers.Id = Orders.CustomerId WHERE Orders.CustomerId IS NULL;
題目sql
SELECT d.Name AS Department, e.Name AS Employee, e.Salary FROM Department d, Employee e WHERE e.DepartmentId = d.id AND (e.Salary, e.DepartmentId) IN (SELECT max(Salary), DepartmentId FROM Employee GROUP BY DepartmentId);
題目code
解答blog
SELECT d.Name AS Department, e1.Name AS Employee, e1.Salary FROM Employee e1, Department d WHERE e1.DepartmentId = d.Id AND 3 > (SELECT COUNT(DISTINCT e2.Salary) FROM Employee AS e2 WHERE e1.Salary < e2.Salary AND e1.DepartmentId = e2.DepartmentId) -- primary key只能是Department,不能夠是Id ORDER BY d.Name, Salary DESC;
我如今也不知道主鍵那裏究竟是爲何it
DELETE FROM Person WHERE id NOT IN (SELECT need.id FROM ((SELECT MIN(Id) as id FROM Person GROUP BY Email) AS need));
SELECT a.Id FROM Weather a JOIN Weather b ON a.Temperature > b.Temperature AND DATEDIFF(a.RecordDate, b.RecordDate) = 1;