diff --git a/1204-last-person-to-fit-in-the-bus/1204-last-person-to-fit-in-the-bus.sql b/1204-last-person-to-fit-in-the-bus/1204-last-person-to-fit-in-the-bus.sql new file mode 100644 index 0000000..b90bb33 --- /dev/null +++ b/1204-last-person-to-fit-in-the-bus/1204-last-person-to-fit-in-the-bus.sql @@ -0,0 +1,3 @@ +# Write your MySQL query statement below + +SELECT person_name FROM (SELECT person_id, person_name, turn, weight, SUM(weight) over (ORDER BY turn) AS total_weight FROM Queue ORDER BY turn) TotalWeightTable WHERE total_weight <= 1000 ORDER BY total_weight DESC LIMIT 1; \ No newline at end of file