Advertisement
imk0tter

Untitled

Feb 18th, 2012
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.95 KB | None | 0 0
  1. SELECT
  2.     B.GroupBy,
  3.     COALESCE(SUM(A.AuditCount),0) AS AuditCount,
  4.     COALESCE(SUM(A.AuditTimerCount),0) AS AuditTimerCount,
  5.     COALESCE(AVG(A.AuditAvgTimer),0) AS AuditAvgTimer,
  6.    
  7.     COALESCE(SUM(A.AuditCNTCount),0) AS AuditCNTCount,
  8.     COALESCE(SUM(A.AuditCNTTimerCount),0) AS AuditCNTTimerCount,
  9.     COALESCE(AVG(A.AuditCNTAvgTimer),0) AS AuditCNTAvgTimer,
  10.    
  11.     COALESCE(SUM(A.AuditWTOCount),0) AS AuditWTOCount,
  12.     COALESCE(SUM(A.AuditWTOTimerCount),0) AS AuditWTOTimerCount,
  13.     COALESCE(AVG(A.AuditWTOAvgTimer),0) AS AuditWTOAvgTimer,
  14.    
  15.     COALESCE(SUM(A.AuditPassCount),0) AS AuditPassCount,
  16.     COALESCE(SUM(A.AuditPassTimerCount),0) AS AuditPassTimerCount,
  17.     COALESCE(AVG(A.AuditPassAvgTimer),0) AS AuditPassAvgTimer,
  18.    
  19.     COALESCE(SUM(A.AuditFailCount),0) AS AuditFailCount,
  20.     COALESCE(SUM(A.AuditFailTimerCount),0) AS AuditFailTimerCount,
  21.     COALESCE(AVG(A.AuditFailAvgTimer),0) AS AuditFailAvgTimer,
  22.    
  23.     COALESCE(SUM(A.QCCount),0) AS QCCount,
  24.     COALESCE(SUM(A.QCTimerCount),0) AS QCTimerCount,
  25.     COALESCE(AVG(A.QCAvgTimer), 0) AS QCAvgTimer,
  26.    
  27.     COALESCE(SUM(A.QCPassCount),0) AS QCPassCount,
  28.     COALESCE(SUM(A.QCPassTimerCount),0) AS QCPassTimerCount,
  29.     COALESCE(AVG(A.QCPassAvgTimer), 0) AS QCPassAvgTimer,
  30.    
  31.     COALESCE(SUM(A.QCFailCount),0) AS QCFailCount,
  32.     COALESCE(SUM(A.QCFailTimerCount),0) AS QCFailTimerCount,
  33.     COALESCE(AVG(A.QCFailAvgTimer), 0) AS QCFailAvgTimer,
  34.    
  35.     COALESCE(SUM(A.ReceiveCount),0) AS ReceiveCount,
  36.     COALESCE(SUM(A.ReceiveTimerCount), 0) AS ReceiveTimerCount,
  37.     COALESCE(AVG(A.ReceiveAvgTimer), 0) AS ReceiveAvgTimer,
  38.    
  39.     COALESCE(SUM(A.RepairCount),0) AS RepairCount,
  40.     COALESCE(SUM(A.RepairJobEntryCount), 0) AS RepairJobEntryCount,
  41.     COALESCE(SUM(A.RepairTimerCount),0) AS RepairTimerCount,
  42.     COALESCE(AVG(A.RepairAvgTimer),0) AS RepairAvgTimer,
  43.        
  44.     COALESCE(SUM(A.RepairPassCount),0) AS RepairPassCount,
  45.     COALESCE(SUM(A.RepairPassJobEntryCount), 0) AS RepairPassJobEntryCount,
  46.     COALESCE(SUM(A.RepairPassTimerCount),0) AS RepairPassTimerCount,
  47.     COALESCE(AVG(A.RepairPassAvgTimer),0) AS RepairPassAvgTimer,
  48.    
  49.     COALESCE(SUM(A.RepairCBFCount),0) AS RepairCBFCount,
  50.     COALESCE(SUM(A.RepairCBFJobEntryCount), 0) AS RepairCBFJobEntryCount,
  51.     COALESCE(SUM(A.RepairCBFTimerCount),0) AS RepairCBFTimerCount,
  52.     COALESCE(AVG(A.RepairCBFAvgTimer),0) AS RepairCBFAvgTimer,
  53.    
  54.     COALESCE(SUM(A.RefurbishCount),0) AS RefurbishCount,
  55.     COALESCE(SUM(A.RefurbishJobEntryCount),0) AS RefurbishJobEntryCount,
  56.     COALESCE(SUM(A.RefurbishTimerCount),0) AS RefurbishTimerCount,
  57.     COALESCE(AVG(A.RefurbishAvgTimer),0) AS RefurbishAvgTimer,
  58.    
  59.     COALESCE(SUM(A.TechCount),0) AS TechCount,
  60.     COALESCE(SUM(A.TechJobEntryCount),0) AS TechJobEntryCount,
  61.     COALESCE(SUM(A.TechTimerCount), 0) AS TechTimerCount,
  62.     COALESCE(AVG(A.TechAvgTimer),0) AS TechAvgTimer
  63. FROM
  64.     (
  65.         SELECT
  66.             A.EntryDate,
  67.             CAST(1 AS INTEGER) AS GroupBy
  68.         FROM
  69.             DateTable AS A     
  70.     ) AS B
  71.     INNER JOIN
  72.     DatabaseReportQuery AS A
  73.     ON A.EntryDate = B.EntryDate
  74. WHERE
  75.     B.EntryDate BETWEEN @Param1 AND @Param2
  76. GROUP BY
  77.     B.GroupBy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement