Advertisement
imk0tter

Untitled

Feb 14th, 2012
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.55 KB | None | 0 0
  1. SELECT
  2.     A.FirstName,
  3.     A.LastName,
  4.     A.EmployeeID,
  5.     A.TimePerPhone,
  6.     A.PhonesPerDay,
  7.     B.PhonesToday
  8. FROM
  9.     (SELECT
  10.         A.FirstName,
  11.         A.LastName,
  12.         A.EmployeeID,
  13.         AVG(B.Timer) AS TimePerPhone,
  14.         COUNT(DISTINCT B.AuditID) AS PhonesPerDay,
  15.         DATE(B.AuditDate) AS AuditDate
  16.     FROM
  17.         EmployeeTable AS A,
  18.         AuditTable AS B
  19.     WHERE
  20.         A.EmployeeID = B.EmployeeID
  21.     GROUP BY
  22.         A.FirstName,
  23.         A.LastName,
  24.         A.EmployeeID,
  25.         AuditDate
  26.     ORDER BY
  27.         AuditDate DESC
  28.     ) AS A
  29. GROUP BY
  30.     A.FirstName,
  31.     A.LastName,
  32.     A.EmployeeID,
  33. ORDER BY
  34.     PhonesToday DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement