So, I have this SQL table:
Traveller checkin dateTime
5566 Madrid 2017-01-01 01:00:00.00
5566 Barcelona 2017-01-02 03:00:00.00
5566 Berlin 2017-01-03 02:00:00.00
5566 Paris 2017-01-06 05:00:00.00
5566 London 2017-01-07 06:00:00.00
5566 Madrid 2017-01-08 02:00:00.00
4422 Moscow 2017-01-03 08:00:00.00
4422 Madrid 2017-01-04 07:00:00.00
4422 Barcelona 2017-01-05 03:00:00.00
8833 Barcelona 2017-02-01 08:00:00.00
8833 Berlin 2017-02-02 04:00:00.00
8833 London 2017-02-03 01:00:00.00
8833 Berlin 2017-02-03 22:00:00.00
9966 Paris 2017-02-03 04:00:00.00
9966 London 2017-02-04 06:00:00.00
9966 Berlin 2017-02-05 01:00:00.00
... ... ...
Is it possible to somehow order these into a from-to table, using all but the first checkin as both a from and to destination. Like this:
Traveller From To
5566 Madrid Barcelona
5566 Barcelona Berlin
5566 Berlin Paris
5566 Paris London
5566 London Madrid
4422 Moscow Madrid
4422 Madrid Barcelona
8833 Barcelona Berlin
8833 Berlin London
8833 London Berlin
... ... ...
I know the basics of SQL but I'm still learning, so if anyone can think of a way this could be done (or not), help me understand how it works.
Thanks a lot!