#109. [LeetCode / MySQL] 1204. Last Person to Fit in the Bus

문제

 

입력 코드

SELECT q1.person_name
FROM Queue AS q1 
JOIN Queue AS q2 
    ON q1.turn >= q2.turn
GROUP BY q1.turn
HAVING SUM(q2.weight) <= 1000
ORDER BY SUM(q2.weight) DESC
LIMIT 1

 

코드 설명

#SELECT #JOIN #SELF JOIN #GROUP BY #HAVING #SUM #ORDER BY #LIMIT

 

 

문제 출처

 

LeetCode - The World's Leading Online Programming Learning Platform

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com