|
| 1 | +# [Lift Overloaded](https://www.namastesql.com/coding-problem/15-lift-overloaded-part-1) |
| 2 | + |
| 3 | +[](https://github.com/thecoddiwompler/SQL-Practice-Questions/tree/main) |
| 4 | +[](https://github.com/thecoddiwompler?tab=repositories) |
| 5 | +[](https://github.com/thecoddiwompler) |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🛠️ Problem Statement |
| 10 | + |
| 11 | + <b>Table Name : lifts</b> |
| 12 | + |
| 13 | +| Column Name |Type | |
| 14 | +| ------------- | ------------- | |
| 15 | +| id | int | |
| 16 | +| capacity_kg | int | |
| 17 | + |
| 18 | + |
| 19 | + <b>Table Name : lift_passengers</b> |
| 20 | + |
| 21 | +| COLUMN_NAME | DATA_TYPE | |
| 22 | +| ------------- | ------------- | |
| 23 | +| passenger_name | varchar(10) | |
| 24 | +| weight_kg | int | |
| 25 | +| lift_id | int | |
| 26 | + |
| 27 | +You are given a table of list of lifts , their maximum capacity and people along with their weight who wants to enter into it. You need to make sure maximum people enter into the lift without lift getting overloaded. |
| 28 | + |
| 29 | +For each lift, Write a SQL Query to find the comma separated list of people who can be accommodated. The comma separated list should have people in the order of their weight in increasing order. |
| 30 | + |
| 31 | +Display the output in increasing order of id. |
| 32 | + |
| 33 | + <details> |
| 34 | +<summary> |
| 35 | +Input |
| 36 | +</summary> |
| 37 | +<br> |
| 38 | + |
| 39 | + <b>Table Name: lifts</b> |
| 40 | + |
| 41 | +| id |capacity_kg | |
| 42 | +| ------------- | ------------- | |
| 43 | +| 1 | 250 | |
| 44 | +| 2 | 280 | |
| 45 | + |
| 46 | +<b>Table Name: lift_passengers</b> |
| 47 | + |
| 48 | +| passenger_name | weight_kg | lift_id | |
| 49 | +| ------------- | ------------- | --- | |
| 50 | +| Dheeraj | 78 | 1 | |
| 51 | +| Adarsh | 70 | 1 | |
| 52 | +| Rahul | 80 | 1 | |
| 53 | +| Srinivas | 85 | 1 | |
| 54 | +| Dushyant | 95 | 1 | |
| 55 | +| Priti | 50 | 2 | |
| 56 | +| Neha | 53 | 2 | |
| 57 | +| Vimal | 58 | 2 | |
| 58 | +| Himanshi | 62 | 2 | |
| 59 | +| Akshay | 73 | 2 | |
| 60 | +| Devendra | 78 | 2 | |
| 61 | +| Amrendra | 83 | 2 | |
| 62 | + |
| 63 | + |
| 64 | +</details> |
| 65 | + |
| 66 | +<details> |
| 67 | +<summary> |
| 68 | +Output |
| 69 | +</summary> |
| 70 | + |
| 71 | +<br> |
| 72 | + |
| 73 | +| id | passenger_list | |
| 74 | +|----|---------------------------| |
| 75 | +| 1 | Adarsh,Dheeraj,Rahul | |
| 76 | +| 2 | Priti,Neha,Vimal,Himanshi | |
0 commit comments