You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with new as(
select
turn, person_name, weight, sum(weight) over(order by turn asc) totalweight
from Queue
order by turn
)
select person_name
from Queue q
whereq.turn=(selectmax(turn) from new where totalweight<=1000)
selectp1.person_namefrom (
select person_name, weight, turn, sum(weight) over(order by turn rows between unbounded preceding and current row) as"Total Weight"from Queue
) as p1 where p1.`Total Weight`<=1000order by p1.`Total Weight`desclimit1