Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- B.PhonesPerDay AS PhonesToday
- AVG(A.TimePerPhone),
- AVG(A.PhonesPerDay)
- FROM
- (SELECT
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- AVG(B.Timer) AS TimePerPhone,
- COUNT(DISTINCT B.AuditID) AS PhonesPerDay,
- CONVERT(DATE, B.AuditDate) AS AuditDate
- FROM
- EmployeeTable AS A,
- AuditTable AS B
- WHERE
- A.EmployeeID = B.EmployeeID
- GROUP BY
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- AuditDate
- ORDER BY
- AuditDate DESC
- ) AS A,
- (SELECT
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- AVG(B.Timer) AS TimePerPhone,
- COUNT(DISTINCT B.AuditID) AS PhonesPerDay,
- CONVERT(DATE, B.AuditDate) AS AuditDate
- FROM
- EmployeeTable AS A,
- AuditTable AS B
- WHERE
- A.EmployeeID = B.EmployeeID
- AND
- AuditDate = GETDATE()
- GROUP BY
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- AuditDate
- ORDER BY
- AuditDate DESC
- ) AS B
- WHERE
- A.EmployeeID = B.EmployeeID
- GROUP BY
- A.FirstName,
- A.LastName,
- A.EmployeeID,
- PhonesToday
- ORDER BY
- PhonesToday DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement