Hello
I have created the following Query in SQL which works:
SELECT PT.[Date] , PT.[Customer Reference] , PT.[Agent] , PT.[Contact Reason] , AC.[Total Records] FROM (SELECT e2util_dateandtime AS [Date] , e2sww_customerrefnumber AS [Customer Reference] , e2util_agentname AS [Agent] , e2util_contactreasonname AS [Contact Reason] FROM dbo.Filterede2util_customercontact WHERE e2util_dateandtime >= '29/08/2014' AND e2util_enquiryclassname = 'Customer Moves' AND e2util_origin = '354790000' AND e2util_directioncode = '0' AND (e2util_agentname = 'a' OR e2util_agentname = 'b' OR e2util_agentname = 'c') AND (e2sww_customerrefnumber LIKE '1%' OR e2sww_customerrefnumber LIKE '2%' OR e2sww_customerrefnumber LIKE '3%')) AS PT INNER JOIN (SELECT e2sww_customerrefnumber AS [Customer Reference] , SUM(1) AS [Total Records] FROM dbo.Filterede2util_customercontact WHERE e2util_dateandtime >= '29/08/2014' AND e2util_origin = '354790000' AND e2util_directioncode = '0' GROUP BY e2sww_customerrefnumber) AS AC ON PT.[Customer Reference] = AC.[Customer Reference]
This pulls back all Contacts in our Database that have been logged by a specific person. The final column then does a sum of all contacts that have the same reference number.
What I need is a sum of all contacts that have the same reference number that takes place after the Date and Time of the original contact in the first SELECT QUERY.
I have no idea how to achieve this. Any support?
Thanks
Matthew