취준/코팅 테스트20 [LeetCode] - 586. Customer Placing the Largest Number of Orders 문제 Write a solution to find the customer_number for the customer who has placed the largest number of orders. The test cases are generated so that exactly one customer will have placed more orders than any other customer. 문제 풀이 SELECT customer_number FROM Orders GROUP BY customer_number ORDER BY COUNT(*) DESC LIMIT 1 오답 이유 1. Having으로 풀려고 했음. 2. Order By 뒤에는 변수명만 들어간다고 착각함. 3. DESC, LIMIT 1 하는 거.. 2024. 3. 25. [LeetCode] - 577.Employee Bonus 문제 Write a solution to report the name and bonus amount of each employee with a bonus less than 1000. Return the result table in any order. The result format is in the following example. 문제 해결 SELECT e.name, b.bonus FROM Employee AS e LEFT JOIN Bonus AS b ON e.empId = b.empId WHERE b.bonus IS NULL 쓰면 됩니당.... 2024. 3. 18. [LeetCode] - 176.Second Higest Salary 문제 https://leetcode.com/problems/second-highest-salary/ Write a solution to find the second highest salary from the Employee table. If there is no second highest salary, return null (return None in Pandas). The result format is in the following example. 풀이 SELECT MAX(salary) AS SecondHighestSalary FROM Employee WHERE salary ( SELECT MAX(salary) FROM Employee ) 오답 이유 1. 서브 쿼리가 바로 떠오르지 않았음. 2. 가장 .. 2024. 3. 13. [LeetCode] 1407. Top Travellers 문제 https://leetcode.com/problems/top-travellers/description/ Write a solution to report the distance traveled by each user. Return the result table ordered by travelled_distance in descending order, if two or more users traveled the same distance, order them by their name in ascending order. 문제 해답 SELECT u.name AS name , IFNULL(SUM(r.distance),0) AS travelled_distance FROM Users AS u LEFT JOIN R.. 2024. 3. 12. 이전 1 2 3 4 5 다음