I have table 1
below with data for calls coming to a center
Date | StartTime | EndTime | Calling party | Reason | Notes
---------------------------------------------------------------------------
2017-02-2 | 09:09:17 | 09:10:50 | 1234567890 | General | Activity
2017-02-2 | 09:15:50 | 09:16:45 | 1234567890 | General | Check balance
2017-02-2 | 09:21:04 | 09:21:37 | 1234567890 | General | Close
2017-02-2 | 09:22:52 | 09:23:18 | 1234567890 | General | Transfer
2017-02-2 | 10:16:42 | 10:18:51 | 4455667788 | Helpcntr| NULL
2017-02-2 | 10:23:07 | 10:24:48 | 4455667788 | Helpcntr| Check accnt
2017-02-2 | 10:30:22 | 10:31:32 | 4455667788 | Helpcntr| Apply
... | ... | ... | ... | ... | ...
What I am trying to do is merge all the calls that have the same phone number with having the earliest StartTime
and the latest EndTime
as shown below
Date | StartTime | EndTime | Calling party | Reason | Notes
---------------------------------------------------------------------------
2017-02-2 | 09:09:17 | 09:23:18 | 1234567890 | General | Activity
2017-02-2 | 10:16:42 | 10:31:32 | 4455667788 | Helpcntr| NULL
... | ... | ... | ... | ... | ...
Note that Notes
and Reason
column are not as important as the rest of the columns but it would be great to be able to put the strings from all the rows in one row such as
Date | StartTime | EndTime | Calling party | Reason | Notes
--------------------------------------------------------------------------------------------
2017-02-2 | 09:09:17 | 09:23:18 | 1234567890 | General | Activity,Check balance, Close, Transfer
2017-02-2 | 10:16:42 | 10:31:32 | 4455667788 | Helpcntr| Check accnt, Apply
... | ... | ... | ... | ... | ...
All the answers I found did not involve time since it repeats everyday. I was not able to get it right since the data is huge and is for the whole year