select lift_id,group_concat(passenger_names) as passengers_name from (select l.id as lift_id, l.capacity_kg as lift_capacity, lp.passenger_name as passenger_names, lp.weight_kg, sum(lp.weight_kg) over (partition by lp.lift_id order by lp.lift_id,lp.weight_kg) as running_total from lifts l join lift_passengers lp on l.id=lp.lift_id group by 1,2,3,4 order by 1,2) as x where running_total
🎉❤🎉
insert into lift_passengers values ('Rahul', 85, 1);
insert into lift_passengers values ('Adarsh', 73, 1);
insert into lift_passengers values ('Riti', 95, 1);
insert into lift_passengers values ('Dheeraj', 80, 1);
insert into lift_passengers values ('Vimal', 83, 2);
insert into lift_passengers values ('Neha', 77, 2);
insert into lift_passengers values ('Priti', 73, 2);
insert into lift_passengers values ('Himanshi', 85, 2);
❤️
Insert statement of lift_passengers table is missing
insert into lift_passengers values ('Rahul', 85, 1);
insert into lift_passengers values ('Adarsh', 73, 1);
insert into lift_passengers values ('Riti', 95, 1);
insert into lift_passengers values ('Dheeraj', 80, 1);
insert into lift_passengers values ('Vimal', 83, 2);
insert into lift_passengers values ('Neha', 77, 2);
insert into lift_passengers values ('Priti', 73, 2);
insert into lift_passengers values ('Himanshi', 85, 2);
use this insert
select lift_id,group_concat(passenger_names) as passengers_name from
(select l.id as lift_id,
l.capacity_kg as lift_capacity,
lp.passenger_name as passenger_names,
lp.weight_kg,
sum(lp.weight_kg) over (partition by lp.lift_id order by lp.lift_id,lp.weight_kg) as running_total
from lifts l join lift_passengers lp
on l.id=lp.lift_id
group by 1,2,3,4
order by 1,2) as x
where running_total