Table Name : travel_data
Column Name | Type |
---|---|
customer | varchar(20) |
start_loc | varchar(50) |
end_loc | varchar(50) |
This table contains data about passengers traveling between various cities.
You are given the travel data for each customer in no particular order.
Write a SQL to find the start location and end location of the customer and total number of locations covered by them.
The query result format is in the following example:
Input
Table Name: travel_data
customer | start_loc | end_loc |
---|---|---|
c1 | New York | Lima |
c1 | London | New York |
c1 | Lima | Sao Paulo |
c1 | Sao Paulo | New Delhi |
c2 | Mumbai | Hyderabad |
c2 | Surat | Pune |
c2 | Hyderabad | Surat |
c3 | Kochi | Kurnool |
c3 | Lucknow | Agra |
c3 | Agra | Jaipur |
c3 | Jaipur | Kochi |
Output
customer | start_loc | end_loc | place_visited |
---|---|---|---|
c1 | London | New Delhi | 5 |
c2 | Mumbai | Pune | 4 |
c3 | Lucknow | Kurnool | 5 |