I have a table in the format below:
|name |visited_property|visit_date_time |
|Marry|Residence_inn |05-25-2020 15:00:01|
|Marry|Residence_inn |05-25-2020 15:15:01|
|Marry|Residence_inn |05-25-2020 15:30:01|
|Marry|Hilton_garden |05-25-2020 17:10:01|
|Marry|Marriott_hotel |05-25-2020 18:10:01|
|Harry|Hilton_garden |05-26-2020 10:10:01|
|Harry|Residence_inn |05-26-2020 12:10:01|
|Harry|Hilton_garden |05-26-2020 15:10:01|
I want to write a query to get the list of distinct properties (and order of visit) they visit. If they visit the same property consecutively, I'd like to count that as 1 visit. If they visit the same property non-consecutively, I'd like to count the visits separately.
Ideally I would like to replicate the table and get rid of the consecutive duplicates to have something that looks like this (getting rid of Marry's 2nd and 3rd visit to Residence Inn since it's 3 visits to that property in a row, while keeping Harry's both visits to Hilton garden since they are non-consecutive):
|name |visited_property|visit_date_time |
|Marry|Residence_inn |05-25-2020 15:00:01|
|Marry|Hilton_garden |05-25-2020 17:10:01|
|Marry|Marriott_hotel |05-25-2020 18:10:01|
|Harry|Hilton_garden |05-26-2020 10:10:01|
|Harry|Residence_inn |05-26-2020 12:10:01|
|Harry|Hilton_garden |05-26-2020 15:10:01|
What SQL statement can I use? Appreciate your help.