From 58c9797242dfb3158131ac09f151d02183c8ccfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Chac=C3=B3n=20Guti=C3=A9rrez?= <138903866+joseantoniochacon@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:46:44 -0600 Subject: [PATCH] Time: 729 ms (82.65%), Space: 0B (100.00%) - LeetHub --- .../1204-last-person-to-fit-in-the-bus.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 1204-last-person-to-fit-in-the-bus/1204-last-person-to-fit-in-the-bus.sql 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