Skip to content

Tag: sql

Find the timestamp of a unique ticket number

I have a table that looks like this: There are 400,000 rows. The ActivityNumber is a unique ticket number with the activity count attached. There are 4 teams. Each activitynumber is in the table. I need to calculate the average time taken between updates for each team, for each month (to see how each team is …

TSQL find number of correspondences

I have the following table: Test Data: I need to find out how many times correspondence has been between each pair. For example, Anthony has contacted John 5 times, John has contacted Anthony 5 times. So total correspondence between John and Anthony has been 10 times. Similarly, David has contacted John total…

Using distinct with stuff/for xml path(”)

I’d like to put together only unique values in the concatenated string. My code is currently: This gives me the output I’d expect, but I would like to eliminate the duplicate values in the stuff/for xml path field. I’ve tried various combinations of distinct and group by in the stuff/xml sec…