我有一个 SQL 语句,我试图提取所有 JobTypes 的总和,例如,如果有 5 个名为“Process”的作业,它们应该只显示在一行上,其中包含 GB 和 KB 的总和。我该如何做到这一点?谢谢。
所以我会显示: - jpavlov 10 分钟前
2012 年 12 月 1 日,Data Extrat,sum(60),sum(56) - jpavlov 8 分钟前
,2012 年 12 月 1 日,Process,sum(60),sum(56)
SELECT
Jobs.DateCompleted AS 'DateCompleted',
JobTypes.Name AS 'JobName',
SUM(Metrics.GB) AS GB,
SUM(Metrics.KB) AS KB
FROM Metrics
INNER JOIN
Jobs ON Jobs.JobId = Metrics.JobId
INNER JOIN
Projects ON Projects.ProjectId = Jobs.ProjectId
INNER JOIN
JobTypes ON JobTypes.JobTypeId = Jobs.JobTypeId
WHERE Jobs.DateCompleted
Between '12/01/2012' AND '12/03/2012'
GROUP BY
Jobs.DateCompleted,
JobTypes.Name
2012-12-01 04:28:15.477 Data Extract 0.200 210903.738
2012-12-01 04:40:07.913 Data Extract 0.781 819388.602
2012-12-01 04:48:45.493 Data Extract 5.278 5538731.844
2012-12-01 04:54:55.483 Data Extract 6.927 7265870.682
2012-12-01 14:11:38.357 Export 13.189 13828648.369
2012-12-01 16:57:54.840 Process 2.054 2156185.331