我有这个 T-sql 来获取当月每个销售代表对客户的计数我想问一下如何应用 avg 函数来获取当月的平均访问
SELECT COUNT(VisitTracking.customerID) AS #VISIT,
MAX(VisitTracking.visitID) AS VisitID,
Customers.title AS Title,
Customers.firstName AS [First Name],
Customers.LastName AS [Last Name],
Company.companyName AS [Company Name],
MAX(VisitTracking.DateVisited) AS [Date Visited],
CONVERT(DATE, MAX(VisitTracking.nextVisit)) AS [Next Visit],
Customers.customerID
FROM VisitTracking
INNER JOIN Customers ON VisitTracking.customerID = Customers.customerID
INNER JOIN Customer_Company ON Customers.customerID = Customer_Company.customerID
INNER JOIN Company ON Customer_Company.companyID = Company.companyID
WHERE VisitTracking.DateVisited BETWEEN '11/01/2012' AND '11/31/2012'
GROUP BY Customers.title, Customers.firstName, Customers.LastName, Company.companyName, Customers.customerID