Have a table like:
ID. | Start | End | Item \
Kate 1-Jan 31-Jan Apple\
Kate 1-Feb 28-Feb Apple\
Kate 1-Mar 15-Mar Apple\
John 1-Jan 31-Jan Apple\
John 1-Feb 28-Feb Apple\
John 1-Mar 31-Mar Apple\
Kate 16-Mar 31-Mar Banana\
Kate 1-Apr 30-Apr Banana\
Kate 1-May 31-May Apple\
Kate 1-Jun 15-Jun Apple
The output wanted is below:\
ID | Start | End | Item\
Kate 1-Jan 15-Mar Apple\
John 1-Jan 31-Mar Apple\
Kate 16-Mar 30-Apr Banana\
Kate 1-May 15-Jun Apple
I need to compress the dataset by combine the records start and end date if the customer buys the same item. In my case, if a custom switch from one item and then switch back again, these two period cannot be combined. I have tried "group by ID, Item" clause in sql and it doesn't work for my case as the Kate Apple records will be combined together for one period from 1-Jan to 15-Jun, which is overlapping the Kate Banana period.
Any help will be greatly appreciated!