|
| 1 | +# Trip Details |
| 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 : travel_data</b> |
| 12 | + |
| 13 | +| Column Name |Type | |
| 14 | +| ------------- | ------------- | |
| 15 | +| customer | varchar(20) | |
| 16 | +| start_loc | varchar(50) | |
| 17 | +| end_loc | varchar(50) | |
| 18 | + |
| 19 | +This table contains data about passengers traveling between various cities. </br> |
| 20 | +</br> |
| 21 | + |
| 22 | +You are given the travel data for each customer in no particular order. <br> |
| 23 | +Write a SQL to find the start location and end location of the customer and total number of locations covered by them.</br> |
| 24 | +</br> |
| 25 | + |
| 26 | +The query result format is in the following example: |
| 27 | + |
| 28 | + <details> |
| 29 | +<summary> |
| 30 | +Input |
| 31 | +</summary> |
| 32 | + </br> |
| 33 | + |
| 34 | + <b>Table Name: travel_data</b> |
| 35 | + |
| 36 | +| customer | start_loc | end_loc | |
| 37 | +|----------|------------|------------| |
| 38 | +| c1 | New York | Lima | |
| 39 | +| c1 | London | New York | |
| 40 | +| c1 | Lima | Sao Paulo | |
| 41 | +| c1 | Sao Paulo | New Delhi | |
| 42 | +| c2 | Mumbai | Hyderabad | |
| 43 | +| c2 | Surat | Pune | |
| 44 | +| c2 | Hyderabad | Surat | |
| 45 | +| c3 | Kochi | Kurnool | |
| 46 | +| c3 | Lucknow | Agra | |
| 47 | +| c3 | Agra | Jaipur | |
| 48 | +| c3 | Jaipur | Kochi | |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +</details> |
| 53 | + |
| 54 | +<details> |
| 55 | +<summary> |
| 56 | +Output |
| 57 | +</summary> |
| 58 | +</br> |
| 59 | + |
| 60 | +| customer | start_loc | end_loc | place_visited | |
| 61 | +|----------|-----------|-----------|---------------| |
| 62 | +| c1 | London | New Delhi | 5 | |
| 63 | +| c2 | Mumbai | Pune | 4 | |
| 64 | +| c3 | Lucknow | Kurnool | 5 | |
| 65 | + |
| 66 | + |
| 67 | +</details> |
| 68 | + |
| 69 | +--- |
0 commit comments